Plus Minus

  • + 0 comments
        let positive =0, negative=0, zero = 0
        let finalArr = []
        arr.map((n,i) =>{
            if(n>0) positive++
            if(n<0) negative++
            if(n===0) zero++
        })
        finalArr[0] = (positive / arr.length).toFixed(6)
        finalArr[1] = (negative / arr.length).toFixed(6)
        finalArr[2] = (zero / arr.length).toFixed(6)
        console.log(finalArr.join("\n"))