Learn Form Validation by Building a Calorie Counter - Step 65

Tell us what’s happening:

I am not getting the logic. I have tried in the if block itself. but still it was throwing an error.

Your code so far

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

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

}function getCaloriesFromInputs(list) {
  let calories = 0; // Initialize total calories to 0

  // Loop through each item in the provided list
  for (const item of list) {
    const currVal = cleanInputString(item.value); // Clean the input string
    const invalidInputMatch = isInvalidInput(currVal); // Check for invalid input

    // If there's an invalid input, alert and return null
    if (invalidInputMatch) {
      alert(`Invalid Input: ${invalidInputMatch[0]}`);
      return null; // Exit if there's an invalid input
    }

    // Convert currVal to a number
    const numericValue = Number(currVal);

    // Check if numericValue is a valid number
    if (isNaN(numericValue)) {
      alert(`Invalid Input: '${currVal}' is not a valid number.`);
      return null; // Exit if the conversion to number fails
    }

    // Use addition assignment operator to add the numeric value to total calories
    calories += numericValue; // Add numericValue to calories
  }

  return calories; // Return the total calories
}





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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 65

they were explaining in the step what a numeric value is.
Please take another look at their explanation and the examples showing how to use the Number function. Then attempt the step again. Specifically this part:

You’ll need to use the Number constructor to convert currVal to a number.