You are viewing a single comment's thread. Return to all comments →
JavaScript
function conv(num, arr) { return (num / arr.length).toFixed(6); } function plusMinus(arr) { const counts = arr.reduce((counts, num) => { if (num > 0) counts.pos++; else if (num < 0) counts.neg++; else counts.zero++; return counts; }, { pos: 0, neg: 0, zero: 0 }) console.log(conv(counts.pos, arr)) console.log(conv(counts.neg, arr)) console.log(conv(counts.zero, arr)) }
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 →
JavaScript