Advertisement
AlexandrP

06. Oscars

Nov 25th, 2022
59
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 startPoints = Number(input[1]);
  4.     let judges = Number(input[2]);
  5.     let length = input.length
  6.     let sum = 0
  7.  
  8.  
  9. for (i = 3; i < length; ++i){
  10.     let judgesName = input [i]
  11.     let actorNamePoints = judgesName.length
  12.     let points = input [++i]
  13.     sum = sum + (actorNamePoints * points/2)
  14.    
  15. // console.log(judgesName);
  16. // console.log(actorNamePoints);
  17. // console.log(points);
  18. // console.log(sum);
  19.  
  20.    
  21.  
  22.  
  23. }
  24. sum = sum + startPoints
  25.  
  26. if (sum>=1250.5){
  27.     console.log (`Congratulations, ${actorName} got a nominee for leading role with ${sum.toFixed(1)}!`)
  28.    
  29.        }else{
  30.    
  31.        let = pointsNeeded = 1250.5 - sum;
  32.        console.log(`Sorry, ${actorName} you need ${pointsNeeded.toFixed(1)} more!`);
  33. }
  34.  
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement