Advertisement
Neri0817

06. Oscar

Nov 29th, 2021
1,406
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function oscars(input) {
  2.   let actorName = input[0];
  3.   let points = Number(input[1]);
  4.   let judgeCount = Number(input[2]);
  5.  
  6.   let totalPoints = 0;
  7.  
  8.   for (let i = 3; i < input.length; i++) {
  9.     let judgeName = input[i++];
  10.     let pointsFromJudge = Number(input[i]);
  11.     let judgeNameL = Number(judgeName.length);
  12.     totalPoints = points + (judgeNameL * pointsFromJudge) / 2;
  13.     points = totalPoints;
  14.  
  15.     if (totalPoints > 1250.5) {
  16.       break;
  17.     }
  18.   }
  19.   if (totalPoints > 1250.5) {
  20.     console.log(
  21.       `Congratulations, ${actorName} got a nominee for leading role with ${totalPoints.toFixed(
  22.         1
  23.       )}!`
  24.     );
  25.   } else if (totalPoints < 1250.5) {
  26.     console.log(
  27.       `Sorry, ${actorName} you need ${(1250.5 - totalPoints).toFixed(1)} more!`
  28.     );
  29.   }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement