Learn Form Validation by Building a Calorie Counter - Step 77

Tell us what’s happening:

Can somebody help me guys. I dont understand what I gonna return.

Your code so far

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

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

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 == true){
  return 0;
 }
 
}

// User Editable Region
/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Mobile Safari/537.36

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 77

its looks like u probably want to return net calories or remaining calories from budget.

if(isError == true){
  return 0;
}

** u don’t return anything if there’s no error**, so js will return undefined by default.

1 Like

do you mean here? leave the return keyword without anything in front of it, so the function stops but nothing is returned (well, undefined is returned)

1 Like

nothing happened bro!!! can you please right it down

i do that but nothings happened

No, I can’t write it down

what is your code now?