Plus Minus

  • + 0 comments
    function plusMinus(arr: number[]): void {
        const d: number = arr.length;
        let p: number = 0;
        let z: number = 0;
        let n: number = 0;
        
        arr.forEach((num): number => num > 0 ?  p++ : num < 0 ? n++ : z++);
       
        [p, n, z].forEach((c): void => console.log((c/d).toFixed(6)));
    }