Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tennisRanklist(input) {
- let tournaments = Number(input[0]);
- let startPoints = Number(input[1]);
- let wonTournaments = 0;
- let currentPoints = 0;
- for (let i = 2; i <= tournaments + 1; i++) {
- let stage = input[i];
- if (stage === "W") {
- currentPoints += 2000;
- wonTournaments++;
- } else if (stage === "F") {
- currentPoints += 1200;
- } else if (stage === "SF") {
- currentPoints += 720;
- }
- }
- let totalPoints = startPoints + currentPoints;
- let percentWonTournaments = wonTournaments / tournaments * 100;
- console.log(`Final points: ${totalPoints}`);
- console.log(`Average points: ${Math.floor(currentPoints / tournaments)}`);
- console.log(`${percentWonTournaments.toFixed(2)}%`);
- }
Advertisement
Add Comment
Please, Sign In to add comment