Learn Form Validation by Building a Calorie Counter - Step 65

Tell us what’s happening:

im write this code
function getCaloriesFromInputs(list) {
let calories = 0;

for (const item of list) {
const currVal = cleanInputString(item.value);
const invalidInputMatch = isInvalidInput(currVal);

if (invalidInputMatch) {
  alert(`Invalid Input: ${invalidInputMatch[0]}`);
  isError = true;
  return null;
}
Number(currVal)+= calories ;

}
}
but send to me error massege you should not add an else statement

Your code so far

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

/* file: styles.css */

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

function getCaloriesFromInputs(list) {
  let calories = 0;
  
  for (const item of list) {
    const currVal = cleanInputString(item.value);
    const invalidInputMatch = isInvalidInput(currVal);

    if (invalidInputMatch) {
      alert(`Invalid Input: ${invalidInputMatch[0]}`);
      isError = true;
      return null;
    }
    Number(currVal)+=calories
  }
}

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 65

Use the addition assignment operator to add currVal to your calories total.

This is not correct syntax of addition assignment operator.

Example:

To add variable i to variable sum using the addition assignment operator:

sum += i;

Also, remember to add a semicolon ( ; ) at the end.

u should add the currVal to the calories total and u need to include the Number method to the currVal. it should be like,
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.