Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tennisRanklist(input) {
- let tourney = Number(input.shift());
- let points = Number(input.shift());
- let win = 0;
- let total = 0;
- for (let i = 0; i < tourney; i++) {
- let stage = input.shift();
- switch (stage) {
- case "W":
- total += 2000;
- win++;
- break;
- case "F":
- total += 1200;
- break;
- case "SF":
- total += 720;
- break;
- }
- }
- console.log(`Final points: ${total + points}`);
- console.log(`Average points: ${Math.floor(total / tourney)}`);
- console.log(`${(win / tourney * 100).toFixed(2)}%`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement