-Enigmos-

oscars(colleague).js

Oct 14th, 2021 (edited)
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function oscars(input) {
  2.     let index = 0;
  3.     let actorName = input[index]; //index 0
  4.     index++;
  5.     let totalPoints = Number(input[index]); //index 1
  6.     index++;
  7.     let judgeCount = Number(input[index]); //index 2
  8.     index++; //index 3 next line
  9.     let judgePoints = 0;
  10.     let notNominee = true;
  11.  
  12.     for (let i = 0; i < judgeCount; i++) {
  13.         let currentJudgeName = input[index]; //index 3
  14.         index++;
  15.         let currentJudgePoints = Number(input[index]); //index 4
  16.         index++;
  17.         judgePoints = (currentJudgeName.length * currentJudgePoints) / 2;
  18.         totalPoints += judgePoints;
  19.  
  20.         if (totalPoints >= 1250.5) {
  21.             notNominee = false;
  22.             console.log(`Congratulations, ${actorName} got a nominee for leading role with ${totalPoints.toFixed(1)}!`);
  23.             break;
  24.         }
  25.     }
  26.     let diff = 1250.5 - totalPoints;
  27.  
  28.     if (notNominee) {
  29.         console.log(`Sorry, ${actorName} you need ${diff.toFixed(1)} more!`);
  30.     }
  31.  
  32. }
  33.  
  34. oscars(["Sandra Bullock", "340", "5", "Robert De Niro", "50", "Julia Roberts", "40.5", "Daniel Day-Lewis", "39.4", "Nicolas Cage", "29.9", "Stoyanka Mutafova", "33"]);
Add Comment
Please, Sign In to add comment