Learn Form Validation by Building a Calorie Counter - Step 76

Tell us what’s happening:

This is what the console statement is telling me:
Your if statement should use return to end the function execution.
I am using return in my code, what am I doing wrong? Is this a bug?

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

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

if (isError) {
  isError === truth;
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]);


}

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 76

I don’t understand what this line is for? I don’t think you need it.

Also, you should check the global error flag after you make all the calls to getCaloriesFromInputs.

Looks like you may be missing curly brace.

I don’t think this is true?

Fair enough but I usually see all the const at the top of a script.

I’m not sure what you mean, but I don’t think its related to OP’s issue.

1 Like

I solved it, thanks for your help.

1 Like