0
function must be written to receive only one parameter: an array of notes. It must also return an array with three elements:
The first, with the number of banknotes equal to 0 or 1. Would be the ones who did not like
The second, with the number of notes equal to 2 or 3. Would be those who found average
The third, with the number of banknotes equal to 4 or 5. Would be the ones who liked
notas = [1,1,3,3,5,5]
function calculaGostos(notas){
for(i =0; i <notas.length; i++){
if(notas[i] >=4){
var nGostaram = [notas[i] >=4]
}if (notas <=1) {
var nNaoGostaram = [notas[i] <=1]
} else {
var nMediano = [notas[i] ==2||notas[i] ==3]
}
for each()
return [nGostaram,nNaoGostaram,nMediano]
}
}
Hello Bianca, your question is not clear, and the code you put as example, for being wrong does not help clarify that is the problem, you could add details to your question so that we can help you
– Leo Letto
I’m sorry, Leo, but even I don’t understand the logic of the exercise. But what I wanted to know is how do I retouch how many times an item appears within an array. It’s very compelling by the attention.
– Bianca Kelly
You can add details such as, for example, what this array looks like, whether it’s numbers or string, how do you know which item you’re looking for, if the item is passed as parameter... Things like.
– Leo Letto
I reorganized the code to make it easier to read and tried to use for each but I don’t know the syntax, I tried to multiply the if variables by the amount of elements in the array as well.
– Bianca Kelly