You are viewing a single comment's thread. Return to all comments →
function plusMinus(arr: number[]): void { let zeros = 0 let negatives = 0 let positives = 0 for (const i in arr ){ if (arr[i] > 0 && arr[i] <=100) positives++; if (arr[i] === 0) zeros++; if (arr[i] < 0 && arr[i] >= -100) negatives++; } const z = zeros / arr.length const n = negatives / arr.length const p = positives / arr.length console.log(p.toFixed(6)) console.log(n.toFixed(6)) console.log(z.toFixed(6)) }
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 →
TypeScript Solution