Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function footballLeague(input) {
- let stadiumCapacity = Number(input[0]);
- let allFans = Number(input[1]);
- let fansSectorA = 0;
- let fansSectorB = 0;
- let fansSectorV = 0;
- let fansSectorG = 0;
- for (let i = 1; i <= allFans + 1; i++) {
- let sector = input[i];
- if (sector === "A") {
- fansSectorA++;
- } else if (sector === "B") {
- fansSectorB++;
- } else if (sector === "V") {
- fansSectorV++;
- } else if (sector === "G") {
- fansSectorG++;
- }
- }
- console.log(`${(fansSectorA / allFans * 100).toFixed(2)}%`);
- console.log(`${(fansSectorB / allFans * 100).toFixed(2)}%`);
- console.log(`${(fansSectorV / allFans * 100).toFixed(2)}%`);
- console.log(`${(fansSectorG / allFans * 100).toFixed(2)}%`);
- console.log(`${(allFans / stadiumCapacity * 100).toFixed(2)}%`);
- }
Advertisement
Add Comment
Please, Sign In to add comment