Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let averageTennisPoints = 0;
- let avergaeBadmintonPoints = 0;
- let volleyball = 0;
- let tennis = 0;
- let badminton = 0;
- let totalPoints = 0;
- for(let i = 0; i <= playedGames ; i++){
- let currentGame = input.shift();
- let points = Number(input.shift());
- switch(currentGame) {
- case 'volleyball' :
- points = points * 1.07;
- volleyball++;
- break;
- case 'tennis' :
- points = points * 1.05;
- tennis++;
- break;
- case 'badminton' :
- points = points * 1.02;
- badminton++;
- break;
- }
- if(currentGame == 'volleyball') {
- averageVolleyPoints = Math.floor(points / volleyball);
- } else if (currentGame == 'tennis') {
- averageTennisPoints = Math.floor(points / tennis);
- } else if(currentGame == 'badminton') {
- avergaeBadmintonPoints = Math.floor(points / badminton);
- }
- }
- totalPoints = averageVolleyPoints + averageTennisPoints + avergaeBadmintonPoints;
- if(totalPoints >= 75) {
- console.log(`Congratulations, ${playerName}! You won the cruise games with ${totalPoints} points.`)
- }
- if(totalPoints < 75) {
- console.log(`Sorry, ${playerName}, you lost. Your points are only ${totalPoints}.`)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment