Advertisement
DimiPetrov

PB - Oscars

Jun 4th, 2020
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function oscars(input) {
  2.    let name = input.shift();
  3.    let startPoints = Number(input.shift());
  4.    let tests = Number(input.shift());
  5.    let currentPoints = 0;
  6.  
  7.    for(let i = 1; i <= tests; i++) {
  8.        let actor = input.shift();
  9.        let testPoints = Number(input.shift());
  10.        currentPoints += (actor.length * testPoints) / 2;
  11.    }
  12.      let finalPoints = startPoints + currentPoints;
  13.      if(finalPoints > 1250.5) {
  14.         console.log(`Congratulations, ${name} got a nominee for leading role with ${finalPoints.toFixed(1)}!`);
  15.      } else {
  16.         console.log(`Sorry, ${name} you need ${(1250.5 - finalPoints).toFixed(1)} more!`);
  17.      }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement