ExGiX

asd

Mar 21st, 2020
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. let averageTennisPoints = 0;
  2. let avergaeBadmintonPoints = 0;
  3.  
  4. let volleyball = 0;
  5. let tennis = 0;
  6. let badminton = 0;
  7.  
  8. let totalPoints = 0;
  9.  
  10.  
  11.  
  12. for(let i = 0; i <= playedGames ; i++){
  13. let currentGame = input.shift();
  14. let points = Number(input.shift());
  15.  
  16. switch(currentGame) {
  17. case 'volleyball' :
  18. points = points * 1.07;
  19. volleyball++;
  20. break;
  21. case 'tennis' :
  22. points = points * 1.05;
  23. tennis++;
  24. break;
  25. case 'badminton' :
  26. points = points * 1.02;
  27. badminton++;
  28. break;
  29.  
  30. }
  31.  
  32.  
  33. if(currentGame == 'volleyball') {
  34. averageVolleyPoints = Math.floor(points / volleyball);
  35. } else if (currentGame == 'tennis') {
  36. averageTennisPoints = Math.floor(points / tennis);
  37. } else if(currentGame == 'badminton') {
  38. avergaeBadmintonPoints = Math.floor(points / badminton);
  39. }
  40.  
  41.  
  42.  
  43. }
  44.  
  45. totalPoints = averageVolleyPoints + averageTennisPoints + avergaeBadmintonPoints;
  46.  
  47. if(totalPoints >= 75) {
  48.  
  49. console.log(`Congratulations, ${playerName}! You won the cruise games with ${totalPoints} points.`)
  50. }
  51.  
  52.  
  53.  
  54. if(totalPoints < 75) {
  55. console.log(`Sorry, ${playerName}, you lost. Your points are only ${totalPoints}.`)
  56. }
  57.  
  58.  
  59.  
  60.  
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment