Vassil_Iliev

Oscars

Mar 3rd, 2022
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function oscars(input) {
  2.     let actorName = input[0];
  3.     let academyPoints = +input[1];
  4.     let countOfJury = +input[2];
  5.     let points = academyPoints;
  6.     let juryNamesArr = [];
  7.     let pointsArr = [];
  8.  
  9.     for (let i = 1; i <= countOfJury + countOfJury; i++) {
  10.         if (i % 2 != 0) {
  11.             juryNamesArr.push(input[i + 2])
  12.         }
  13.     }
  14.  
  15.     for (let i = 1; i <= countOfJury + countOfJury; i++) {
  16.         if (i % 2 != 0) {
  17.             pointsArr.push(input[i + 3])
  18.         }
  19.     }
  20.  
  21.     for (let i = 0; i < pointsArr.length; i++) {
  22.         if (points.toFixed(1) > 1250.5) {
  23.             console.log(`Congratulations, ${actorName} got a nominee for leading role with ${points.toFixed(1)}!`);
  24.             break;
  25.         }
  26.         points += (pointsArr[i] * juryNamesArr[i].length) / 2;
  27.     }
  28.     if (points < 1250.5) {
  29.         console.log(`Sorry, ${actorName} you need ${(Math.abs(points - 1250.5)).toFixed(1)} more!`);
  30.     }
  31.  
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment