Advertisement
Guest User

Oscars

a guest
Mar 26th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function oscars(input){
  2.     let actorName = input.shift();
  3.     let score = Number(input.shift());
  4.     let jury = Number(input.shift());    
  5.     let isEnough = false;
  6.     let endLoop = false;  
  7.    
  8.     for (let judge = 1; judge <= jury; judge++){
  9.         let judgeName = input.shift();
  10.         let judgeScore = Number(input.shift());
  11.         let judgeNameIndex = judgeName.length;
  12.         let finalJudgeScore = judgeNameIndex * judgeScore / 2;
  13.         score += finalJudgeScore;
  14.         if (score >= 1250.5){
  15.             isEnough = true;
  16.             break;
  17.         }
  18.         if (judge === jury){
  19.             endLoop = true;
  20.         }
  21.     }
  22.  
  23.     if (isEnough){
  24.         console.log(`Congratulations, ${actorName} got a nominee for leading role with ${score.toFixed(1)}!`);
  25.        
  26.     }
  27.     else if (endLoop) {
  28.         console.log(`Sorry, ${actorName} you need ${(1250.5 - score).toFixed(1)} more!`)
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement