• + 0 comments

    Typescript:

    let result_posative = 0;
    let result_nagative = 0;
    let result_zero = 0;
    for(let i=0;i<arr.length;i++){
       if(arr[i] > 0) {
       result_posative++;
       } else if(arr[i] < 0) {
       result_nagative++;
       } else {
       result_zero++;
       }
    }
    console.log(result_posative / arr.length);
    console.log(result_nagative / arr.length);
    console.log(result_zero / arr.length);