Learn form validation by building a calorie counter - Step 76

Hi! I was working on step 76, and I think I found an error with the autochecker.

I know we are supposed to " Add an if statement to your calculateCalories function that checks the truthiness of your global error flag," after line 50 (after the getCaloriesFromInput() function is called multiple times. However, I didn’t read the question properly and added the new code on line 38, after which it still seemed to work, even though it isn’t supposed to as this wouldn’t achieve the purpose of the new code (since we just set isError = false on line 37).

If I’m misunderstanding something, please let me know! Thanks!

Please share a link to the step and your current code. Thanks

link: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-form-validation-by-building-a-calorie-counter/step-76

code that works but shouldn’t:

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


// this should go at the end of this function
  if(isError) {
    return;
  }

  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]);

}

Yep, that looks like a bug in our test


Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.

1 Like

Hi, sorry. I’m a bit confused. Do I have to report this bug on Github or will a staff member be doing that?

I would recommend you report this on GitHub, per the instructions I posted above. But if you prefer, I can create the issue for you.

1 Like

Alright! I’ll do it, thanks!

2 Likes

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