-3
A virtual store allows its visitors to filter products by price. There is an array of product prices. A programmer has already created a function maisBaratosQue(valor, precos) that returns an array with prices of products cheaper than the value passed as parameter. Another programmer has already created a function maisCarosQue(valor, precos) that returns an array with prices more expensive than the value passed as parameter. It’s your turn!
Create a function precosEntre(valorMenor, valorMaior, precos) that must use the functions maisBaratosQue and maisCarosQue to return the prices that are between the valorMenor and the valorMaior. Your function should then receive two parameters:
valorMenorto represent the minimum value of the prices to be listedvalorMaiorto represent the maximum value of the prices to be listedprecosto represent an array of product prices
It should return an array with all prices between valorMenor and valorMaior
function maisBaratosQue(valor, precos) {
return precos.filter(p => p <= valor);
}
function maisCarosQue(valor, precos){
return precos.filter(p => p >= valor);
}
function precosEntre(valorMaior, valorMenor, precos) {
precos.filter( maisBaratosQue() && maisCarosQue(), valor);
return precosEntre;
}