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