 # Untitled

a guest
Jun 4th, 2020
65
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. function solve(input) {
2.   let team = input.shift();
3.   let sumGames = Number(input.shift());
4.
5.   if (sumGames === 0) {
6.     console.log(`\${team} hasn't played any games during this season.`);
7.  } else {
8.    let wins = 0;
9.    let draws = 0;
10.    let losses = 0;
11.    let points = 0;
12.    for (let i = 1; i <= sumGames; i++) {
13.      let gameType = input.shift();
14.      switch (gameType) {
15.        case 'W':
16.          wins++;
17.          points += 3;
18.          break;
19.        case 'D':
20.          draws++;
21.          points += 1;
22.          break;
23.        case 'L':
24.          losses++;
25.          break;
26.      }
27.    }
28.    let percentWins = (wins / sumGames * 100).toFixed(2);
29.
30.    console.log(`\${team} has won \${points} points during this season.`);
31.    console.log(`Total stats:`);
32.    console.log(`## W: \${wins}`);
33.    console.log(`## D: \${draws}`);
34.    console.log(`## L: \${losses}`);
35.    console.log(`Win rate: \${percentWins}%`);
36.  }
37. }
RAW Paste Data