Daily Coding Challenge - Space Week Day 7: Launch Fuel

Tell us what’s happening:

I am trying my JS code function launchFuel() and in my console.log(), the answer is returned correctly.

But the tests in FCC’s console returns otherwise.

Your code so far

function launchFuel(payload) {
  let totalLoad = payload;
  let initialFuelRequired = totalLoad / 5;
  let currentFuelRequired = totalLoad / 5;

  do {
    totalLoad = payload + initialFuelRequired;
    currentFuelRequired = totalLoad / 5;
    fuelDifference = currentFuelRequired - initialFuelRequired;
    initialFuelRequired = currentFuelRequired;
  } while (fuelDifference >= 1);

  return Math.round(currentFuelRequired * 10) / 10;
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36

Challenge Information:

Daily Coding Challenge - Space Week Day 7: Launch Fuel
https://www.freecodecamp.org/learn/daily-coding-challenge/2025-10-10

Hello, I already fixed the bug! I only found it once I re-read my post. It turns out I did not declare my fuelDifference variable. :laughing:

calling the function in the editor is a first debugging step you should take, it helps to notice these things

1 Like

Thanks, I’ll keep that in mind!

How do I test if I pass the challenge?

def launch_fuel(payload):
f = payload/5
fuel = 0
while f>1:
fuel = fuel + f
f = f/5
else:
return fuel

you can run the tests, if you pass you are told so