Advertisement
Guest User

07. Football League

a guest
Apr 10th, 2020
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function footballLeague (args) {
  2.     let stadiumCapacity = Number (args[0]);
  3.     let fanCnt = Number(args[1]);
  4.     let sectorAFans = 0;
  5.     let sectorBFans = 0;
  6.     let sectorVFans = 0;
  7.     let sectorGFans = 0;
  8.  
  9.     for (let fan = 2; fan <= fanCnt + 1; fan++) {
  10.         if (args[fan] == 'A') {
  11.             sectorAFans ++;
  12.         } else if (args[fan] == 'B') {
  13.             sectorBFans ++;
  14.         } else if (args[fan] == 'V') {
  15.             sectorVFans ++;
  16.         } else if (args[fan] == 'G') {
  17.             sectorGFans ++;
  18.         }
  19.     }
  20.     console.log (`${(sectorAFans / fanCnt * 100).toFixed(2)}%`);
  21.     console.log (`${(sectorBFans / fanCnt * 100).toFixed(2)}%`);
  22.     console.log (`${(sectorVFans / fanCnt * 100).toFixed(2)}%`);
  23.     console.log (`${(sectorGFans / fanCnt * 100).toFixed(2)}%`);
  24.     console.log (`${(fanCnt / stadiumCapacity * 100).toFixed(2)}%`)
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement