Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function footballLeague (args) {
- let stadiumCapacity = Number (args[0]);
- let fanCnt = Number(args[1]);
- let sectorAFans = 0;
- let sectorBFans = 0;
- let sectorVFans = 0;
- let sectorGFans = 0;
- for (let fan = 2; fan <= fanCnt + 1; fan++) {
- if (args[fan] == 'A') {
- sectorAFans ++;
- } else if (args[fan] == 'B') {
- sectorBFans ++;
- } else if (args[fan] == 'V') {
- sectorVFans ++;
- } else if (args[fan] == 'G') {
- sectorGFans ++;
- }
- }
- console.log (`${(sectorAFans / fanCnt * 100).toFixed(2)}%`);
- console.log (`${(sectorBFans / fanCnt * 100).toFixed(2)}%`);
- console.log (`${(sectorVFans / fanCnt * 100).toFixed(2)}%`);
- console.log (`${(sectorGFans / fanCnt * 100).toFixed(2)}%`);
- console.log (`${(fanCnt / stadiumCapacity * 100).toFixed(2)}%`)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement