TZinovieva

Football League

Oct 6th, 2022
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function footballLeague(input) {
  2.     let stadiumCapacity = Number(input[0]);
  3.     let allFans = Number(input[1]);
  4.  
  5.     let fansSectorA = 0;
  6.     let fansSectorB = 0;
  7.     let fansSectorV = 0;
  8.     let fansSectorG = 0;
  9.  
  10.     for (let i = 1; i <= allFans + 1; i++) {
  11.         let sector = input[i];
  12.  
  13.         if (sector === "A") {
  14.             fansSectorA++;
  15.         } else if (sector === "B") {
  16.             fansSectorB++;
  17.         } else if (sector === "V") {
  18.             fansSectorV++;
  19.         } else if (sector === "G") {
  20.             fansSectorG++;
  21.         }
  22.     }
  23. console.log(`${(fansSectorA / allFans * 100).toFixed(2)}%`);
  24. console.log(`${(fansSectorB / allFans * 100).toFixed(2)}%`);
  25. console.log(`${(fansSectorV / allFans * 100).toFixed(2)}%`);
  26. console.log(`${(fansSectorG / allFans * 100).toFixed(2)}%`);
  27. console.log(`${(allFans / stadiumCapacity * 100).toFixed(2)}%`);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment