Advertisement
Guest User

Untitled

a guest
Feb 4th, 2022
140
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 nameActor = input[index];
  4.     index++;
  5.     let points = Number(input[index]);
  6.     index++;
  7.     let juryCount = Number(input[index]);
  8.     index++;
  9.     isNominee = false;
  10.  
  11.     for (let i = 0; i < juryCount; i++) {
  12.         let name = input[index];
  13.         index++;
  14.         let tempPoints = Number(input[index]);
  15.         index++;
  16.  
  17.         points += (name.length * tempPoints) / 2;
  18.  
  19.         if (points > 1250.5) {
  20.             console.log(`Congratulations, ${nameActor} got a nominee for leading role with ${points.toFixed(1)}!`);
  21.             isNominee = true;
  22.             break;
  23.         }
  24.     }
  25.     if (!isNominee) {
  26.         let diff = 1250.5 - points;
  27.         console.log(`Sorry, ${nameActor} you need ${diff.toFixed(1)} more!`);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement