Advertisement
Spocoman

06. Oscars

Dec 24th, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function oscars(input) {
  2.     let name = input[0];
  3.     let points = parseFloat(input[1]);
  4.     let juryNum = parseInt(input[2]);
  5.  
  6.     for (let i = 3; i < juryNum * 2 + 3; i += 2) {
  7.         let juryName = input[i];
  8.         let currentPoint = parseFloat(input[i + 1]);
  9.  
  10.         points += juryName.length * currentPoint / 2;
  11.  
  12.         if (points > 1250.5) {
  13.             break;
  14.         }
  15.     }
  16.  
  17.     if (points > 1250.5) {
  18.         console.log(`Congratulations, ${name} got a nominee for leading role with ${points.toFixed(1)}!`);
  19.     } else {
  20.         console.log(`Sorry, ${name} you need ${(1250.5 - points).toFixed(1)} more!`);
  21.     }
  22. }
  23.  
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement