You are viewing a single comment's thread. Return to all comments →
function plusMinus(arr) { let zero = 0; let positive = 0; let negative = 0; for (let element of arr) { if (element > 0) { positive++; } else if (element < 0) { negative++; } else zero++; } console.log((positive / arr.length).toFixed(6)); console.log((negative / arr.length).toFixed(6)); console.log((zero / arr.length).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 →