Advertisement
Spocoman

Tennis Ranklist

Feb 22nd, 2022
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function tennisRanklist(input) {
  2.     let tourney = Number(input.shift());
  3.     let points = Number(input.shift());
  4.     let win = 0;
  5.     let total = 0;
  6.  
  7.     for (let i = 0; i < tourney; i++) {
  8.         let stage = input.shift();
  9.  
  10.         switch (stage) {
  11.             case "W":
  12.                 total += 2000;
  13.                 win++;
  14.                 break;
  15.             case "F":
  16.                 total += 1200;
  17.                 break;
  18.             case "SF":
  19.                 total += 720;
  20.                 break;
  21.         }
  22.     }
  23.  
  24.     console.log(`Final points: ${total + points}`);
  25.     console.log(`Average points: ${Math.floor(total / tourney)}`);
  26.     console.log(`${(win / tourney * 100).toFixed(2)}%`);
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement