False code passed at step 75 - Learn Form Validation by Building a Calorie Counter

I accidentally added exerciseCalories and budgetCalories into the consumedCalories and it still passed the test

function calculateCalories(e) {
  e.preventDefault();
  isError = false;

  const breakfastNumberInputs = document.querySelectorAll('#breakfast input[type=number]');
  const lunchNumberInputs = document.querySelectorAll('#lunch input[type=number]');
  const dinnerNumberInputs = document.querySelectorAll('#dinner input[type=number]');
  const snacksNumberInputs = document.querySelectorAll('#snacks input[type=number]');
  const exerciseNumberInputs = document.querySelectorAll('#exercise input[type=number]');

  const breakfastCalories = getCaloriesFromInputs(breakfastNumberInputs);
  const lunchCalories = getCaloriesFromInputs(lunchNumberInputs);
  const dinnerCalories = getCaloriesFromInputs(dinnerNumberInputs);
  const snacksCalories = getCaloriesFromInputs(snacksNumberInputs);
  const exerciseCalories = getCaloriesFromInputs(exerciseNumberInputs);
  const budgetCalories = getCaloriesFromInputs([budgetNumberInput]);

  if (isError) {
    return;
  }
  const consumedCalories = breakfastCalories + lunchCalories + dinnerCalories + snacksCalories + exerciseCalories + budgetCalories;

}

In general, if you did what the challenge asks you to do BUT you did more than what is asked, the test will simply pass as long as the right answer exists in your code.
( this is a problem i think of how tests work )

However, when you move to the next step you will see that your code is back on the right track to what is required only.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.