Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function footballTournament(input) {
- let team = input.shift();
- let matches = Number(input.shift());
- let w = 0;
- let d = 0;
- let l = 0;
- let counter = 0;
- for (let i = 0; i < matches && matches > 0; i++) {
- let result = input.shift();
- switch (result) {
- case "W":
- w++;
- break;
- case "D":
- d++;
- break;
- case "L":
- l++;
- break;
- }
- }
- if (matches === 0) {
- console.log(`${team} hasn't played any games during this season.`);
- } else {
- console.log(`${team} has won ${w * 3 + d} points during this season.`);
- console.log("Total stats:");
- console.log(`## W: ${w}`);
- console.log(`## D: ${d}`);
- console.log(`## L: ${l}`);
- console.log(`Win rate: ${(w / matches * 100).toFixed(2)}%`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement