You are viewing a single comment's thread. Return to all comments →
let final ={p:0,n:0,z:0}; for(let i of arr){ if(i===0){ final['z']=(final['z']||0) +1; } if(i<0){ final['n']=(final['n']||0) +1; } if(i>0){ final['p']=(final['p']||0) +1; } } Object.values(final).map(item=>console.log(item/arr.length))
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 →
let final ={p:0,n:0,z:0}; for(let i of arr){ if(i===0){ final['z']=(final['z']||0) +1; } if(i<0){ final['n']=(final['n']||0) +1; } if(i>0){ final['p']=(final['p']||0) +1; } } Object.values(final).map(item=>console.log(item/arr.length))