Advertisement
Mitsanski

06.Oscars

Feb 4th, 2022
1,377
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.lenght * tempPoints) / 2;
  18.  
  19.         if (points > 1250.5) {
  20.             console.log(`Congratulations, ${nameActor} got a nominee for leading role with ${points}`);
  21.             isNominee = true;
  22.             break;
  23.         }
  24.     }
  25.     if (!isNominee) {
  26.         let diff = 1250.5 - points;
  27.         console.log(`Sorry, ${nameActor} you need ${diff} more!`);
  28.     }
  29. }
  30. oscars(["Zahari Baharov",
  31. "205",
  32. "4",
  33. "Johnny Depp",
  34. "45",
  35. "Will Smith",
  36. "29",
  37. "Jet Lee",
  38. "10",
  39. "Matthew Mcconaughey",
  40. "39"])
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement