Advertisement
GalinaKG

Untitled

Apr 6th, 2022
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. function movieStars (input) {
  2. let index = 0;
  3. let budget = Number(input[index]);
  4. index++;
  5. let command = input[index];
  6. let spendMoney = budget;
  7.  
  8. while (command !== "ACTION") {
  9. let nameOfActior = input[index];
  10. index++
  11.  
  12. if (spendMoney <= 0) {
  13. break;
  14. }
  15.  
  16. if (nameOfActior.length <= 15) {
  17. let reward = Number(input[index]);
  18. index++;
  19. spendMoney -= reward;
  20. } else {
  21. spendMoney -= (spendMoney * 0.20);
  22. }
  23.  
  24. command = input[index];
  25.  
  26. }
  27.  
  28. if (spendMoney >= 0) {
  29. console.log(`We are left with ${Math.abs(spendMoney).toFixed(2)} leva.`);
  30. } else {
  31. console.log(`We need ${Math.abs(spendMoney).toFixed(2)} leva for our actors.`)
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement