Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function number(inputData){
- var n = Number(inputData[0]);
- var top = 0;
- var verGood = 0;
- var good = 0;
- var fall = 0;
- var all = 0;
- for(var i = 1; i <= n; i++) {
- var scores = Number(inputData[i]);
- all += scores;
- if (scores > 4.99){
- top ++;
- } else if (scores > 3.99){
- verGood ++;
- } else if (scores > 2.99){
- good ++;
- } else
- fall ++;
- }
- console.log(`Top students: ${(top / n * 100).toFixed(2)}%`);
- console.log(`Between 4.00 and 4.99: ${(verGood / n * 100).toFixed(2)}%`);
- console.log(`Between 3.00 and 3.99: ${(good / n * 100).toFixed(2)}%`);
- console.log(`Fail: ${(fall / n * 100).toFixed(2)}%`);
- console.log(`Average: ${(all / n).toFixed(2)}`);
- }
- number(["10", "3.00", "2.99", "5.68", "3.01", "4", "4", "6", "4.50", "2.44", "5"])
Advertisement
Add Comment
Please, Sign In to add comment