Advertisement
-Enigmos-

oscars.js

Oct 6th, 2021 (edited)
79
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];
  4.     index++;
  5.     let points = Number(input[index]);
  6.     index++;
  7.     let oscarMembers = Number(input[index]);
  8.     index++;
  9.     let notNominee = true;
  10.  
  11.     for (i = 0; i < oscarMembers; i++) {
  12.         let currentMemberName = input[index];
  13.         index++;
  14.         let currentMemberPoints = Number(input[index]);
  15.         index++;
  16.         let memberPoints = (currentMemberName.length * currentMemberPoints) / 2;
  17.         points += memberPoints;
  18.  
  19.         if (points >= 1250.5) {
  20.             notNominee = false;
  21.             console.log(`Congratulations, ${actorName} got a nominee for leading role with ${points.toFixed(1)}!`);
  22.             break;
  23.         }
  24.     }
  25.  
  26.     let diff = Math.abs(points - 1250.5).toFixed(1);
  27.  
  28.     if (notNominee) {
  29.         console.log(`Sorry, ${actorName} you need ${diff} more!`);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement