Advertisement
Spocoman

Movie Stars

Feb 17th, 2022 (edited)
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function movieStars(input) {
  2.     let budget = Number(input[0]);
  3.     let index = 1;
  4.     let command;
  5.  
  6.     while ((command = input[index++]) !== "ACTION" && budget >= 0) {
  7.         if (command.length > 15) {
  8.             budget *= 0.8;
  9.         } else {
  10.             budget -= Number(input[index++]);
  11.         }
  12.     }
  13.  
  14.     if (budget >= 0) {
  15.         console.log(`We are left with ${budget.toFixed(2)} leva.`);
  16.     } else {
  17.         console.log(`We need ${Math.abs(budget).toFixed(2)} leva for our actors.`);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement