Advertisement
Spocoman

Football League

Feb 22nd, 2022
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function footballLeague(input) {
  2.     let stadiumCapacity = parseInt(input[0]);
  3.     let footballFens = parseInt(input[1]);
  4.     let sectorA = 0;
  5.     let sectorB = 0;
  6.     let sectorV = 0;
  7.     let sectorG = 0;
  8.  
  9.     for (let i = 2; i <= footballFens + 1; i++){
  10.         if (input[i] === "A"){
  11.             sectorA++;
  12.         } else if (input[i] === "B"){
  13.             sectorB++;
  14.         } else if (input[i] === "V"){
  15.             sectorV++;
  16.         } else if (input[i] === "G"){
  17.             sectorG++;
  18.         }
  19.     }
  20.     console.log(`${(sectorA / footballFens * 100).toFixed(2)}%`);
  21.     console.log(`${(sectorB / footballFens * 100).toFixed(2)}%`);
  22.     console.log(`${(sectorV / footballFens * 100).toFixed(2)}%`);
  23.     console.log(`${(sectorG / footballFens * 100).toFixed(2)}%`);
  24.     console.log(`${(footballFens / stadiumCapacity * 100).toFixed(2)}%`);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement