We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Here is a javascript solution. These could each be individual lines, but it's more readable to me this way
functionplusMinus(arr){// Complete this functionletpositives=parseFloat(arr.filter(value=>value>0).length/arr.length).toPrecision(6)letnegatives=parseFloat(arr.filter(value=>value<0).length/arr.length).toPrecision(6)letzeroes=parseFloat(arr.filter(value=>value===0).length/arr.length).toPrecision(6)console.log(positives)console.log(negatives)console.log(zeroes)}
Cookie support is required to access HackerRank
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 →
Here is a javascript solution. These could each be individual lines, but it's more readable to me this way