Didart

Oscars

Apr 9th, 2022
663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function oscars(input) {
  2.  
  3.     let name = input[0];
  4.     let startingPoints = Number(input[1]);
  5.  
  6.     for (let index = 3; index < input.length; index++) {
  7.  
  8.         if (index % 2 !== 0) {
  9.             let points = index + 1;
  10.             let total = input[index].length * Number(input[points]) / 2;
  11.             startingPoints += total;
  12.         }
  13.  
  14.         if (startingPoints > 1250.5) {
  15.             break;
  16.         }
  17.     }
  18.  
  19.     if (startingPoints < 1250.5) {
  20.         console.log(`Sorry, ${name} you need ${(1250.5 - startingPoints).toFixed(1)} more!`);
  21.     } else {
  22.         console.log(`Congratulations, ${name} got a nominee for leading role with ${(startingPoints).toFixed(1)}!`);
  23.     }
  24.    
  25. }
  26.  
  27. oscars(["Zahari Baharov", "205", "4", "Johnny Depp", "45", "Will Smith", "29", "Jet Lee", "10", "Matthew Mcconaughey", "39"])
  28.  
Advertisement
Add Comment
Please, Sign In to add comment