0
function maisMenos(valores){
var qtd = valores.length;
var neg = valores.filter(nr=> nr < 0).length;
var pos = valores.filter(nr=> nr > 0).length;
var zer = valores.filter(nr=> nr ==0).length;
var calcNeg = neg / qtd;
var calcPos = pos / qtd;
var calcZer = zer / qtd;
var resultado = [];
var insere = resultado.push(calcPos, calcZer, calcNeg);
return resultado;
}
Although I can simplify some things, I think the only thing wrong is that we missed multiply the
calcNeg
, thecalcPos
and thecalcZer
for 100 each to be right.– Victor Stafusa
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero