Programming Basics – JavaScript [closed]

I am trying to solve this task:

Movie Stars

The accountant of the “Star City” cinema center hires you to write a program that calculates the salaries of the actors. Each production has a budget for actors. Until the “ACTION” command is given, you will receive the name of the actor and their salary. If the actor’s name is longer than 15 characters, their salary will be 20% of the remaining budget at that point. If the budget runs out at any point, the program should stop.

Input

First, read one line from the console:

  • Budget for actors – a floating-point number in the range [1000.0… 2 100 000.0]

Then one or two lines are read repeatedly until the command “ACTION” or until the budget runs out:

  • Actor’s name – a string

If the actor name contains less than or equal to 15 characters:

  • Salary – a floating-point number in the range [250.0… 1 000 000.0]

Output

Print one line on the console:

  • If the budget is enough:

    "We are left with {budget left} USD."
    
  • If the budget is NOT enough:

    "We need {budget needed} USD for our actors."
    

The result must be formatted to the second digit after the decimal point!

This is the code I wrote:

function solve(input) {
  let budget = Number(input.shift());
  let totalSalary = 0;

  while (input.length > 0 && input[0] !== "ACTION") {
    let actorName = input.shift();
    let actorSalary = Number(input.shift());

    if (actorName.length > 15) {
      actorSalary = budget * 0.2;
    }

    if (budget >= actorSalary) {
      budget -= actorSalary;
      totalSalary += actorSalary;
    } else {
      let budgetNeeded = actorSalary - budget;
      console.log(`We need ${budgetNeeded.toFixed(2)} USD for our actors.`);
      return;
    }
  }

  console.log(`We are left with ${budget.toFixed(2)} USD.`);
}

It only passes 60/100 tests. What is my mistake?