You are viewing a single comment's thread. Return to all comments →
function plusMinus(arr) {
const total = arr.length; const totalArray = [0, 0, 0]; arr.forEach((item) => { if (item === 0) { totalArray[2]++; } else if (item > 0) { totalArray[0]++; } else { totalArray[1]++; }
});
totalArray.forEach((count) => {
const newItem = count / total; console.log(newItem.toFixed(6));
plusMinus([-4, 3, -9, 0, 4, 1]);
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 →
function plusMinus(arr) {
});
totalArray.forEach((count) => {
plusMinus([-4, 3, -9, 0, 4, 1]);