You are viewing a single comment's thread. Return to all comments →
My solution in JavaScript:
function plusMinus(arr) { // Write your code here //Variables let arrSize = arr.length; let ratioPositive = 0; let ratioNegative = 0; let ratioZero = 0; //Array Function arr.forEach(value =>{ if(value > 0) ratioPositive++; else if(value < 0) ratioNegative++; else if(value === 0) ratioZero++; } ); ratioPositive /= arrSize; ratioNegative /= arrSize; ratioZero /= arrSize; console.log(ratioPositive.toFixed(6)); console.log(ratioNegative.toFixed(6)); console.log(ratioZero.toFixed(6)); }
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
My solution in JavaScript: