Learn Form Validation by Building a Calorie Counter - Step 76

Tell us what’s happening:

Can anyone help me with this problem i am unable to solve it.

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=== true;) {
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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 76

Hi, can you post all your code? It is hard to explain your mistake if we cannot see everything here so we can show you what the instructions were asking or referring to.

is this about checking the truthiness of the isError variable using an if statement? Cause im having the same issue.

isError is a boolean type variable. So

code removed by mod

is enough.

yeah i just figured it out, for some reason im always way too specific with my code and itll throw errors, its like im overthinking the problem.

yes it is ,did you find the solution?

Thankyou all for replying i found the solution ::::

Code removed by mod

It is great that you solved the challenge, but instead of posting your full working solution, it is best to just mention in general how you figured things out without posting the code.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions.

Toan:

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

1 Like

isError is a boolean type variable. Is what made my brain click on.

1 Like

The error occurs because the code you wrote checks if isError is strictly equal to true (isError === true). However, the exercise asks you to check the “truth” of isError, which means that you only need to check if it is “truthy”, without explicitly comparing it to true. That is, mod edit: solution removed

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.