Untitled
unknown
javascript
a year ago
908 B
2
Indexable
Never
function print(count, total){ if(count === 0){ console.log("0.00%"); } else{ const percentage = (count / total) * 100; console.log(percentage.toFixed(2) + '%') } } function histogram(params) { let n = params[0]; let counterUnder200 = 0; let counter200_399 = 0; let counter400_599 = 0; let counter600_799 = 0; let counterOver800 = 0; for(i = 1; i< params.length; i++){ if(params[i] < 200){ counterUnder200+=1; } else if (params[i] < 400){ counter200_399+=1; } else if (params[i] < 600){ counter400_599+=1; } else if (params[i] < 800){ counter600_799+=1; } else{ counterOver800+=1; } } print(counterUnder200, n); print(counter200_399, n); print(counter400_599, n); print(counter600_799, n); print(counterOver800, n); } histogram(["3", "1", "2", "999"]);