Learn Form Validation by Building a Calorie Counter - Step 63

Tell us what’s happening:

it is not passing my code and it gives me a hint saying i should call the alert() function in my if block. i need help

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) {
      const alert() = `("Invalid Input: " + invalidInputMatch)'
    }
  }
}

// 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/126.0.0.0 Safari/537.36

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 63

hi there!
the alert function do not need const keyword and assignment. you only need to pass the required string and array value within alert() funtcion.

template literals should be goes around the string and the first value of invalidInputMatch array within the alert parentheses (). remmeber, the string "Invalid Input" does not need the qoute marks around it. also you need to use template literals syntex ${} for the invalidInputMatch array first value.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.