Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function movieStars (input) {
- let index = 0;
- let budget = Number(input[index]);
- index++;
- let command = input[index];
- let spendMoney = budget;
- while (command !== "ACTION") {
- let nameOfActior = input[index];
- index++
- if (spendMoney <= 0) {
- break;
- }
- if (nameOfActior.length <= 15) {
- let reward = Number(input[index]);
- index++;
- spendMoney -= reward;
- } else {
- spendMoney -= (spendMoney * 0.20);
- }
- command = input[index];
- }
- if (spendMoney >= 0) {
- console.log(`We are left with ${Math.abs(spendMoney).toFixed(2)} leva.`);
- } else {
- console.log(`We need ${Math.abs(spendMoney).toFixed(2)} leva for our actors.`)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement