Learn Form Validation by Building a Calorie Counter - Step 61

Tell us what’s happening:

Hi! I have already read the exercise multiple times and i still cant figure out why my answer is not working.

I get the following error: You should use template literal syntax to display the first value in the invalidInputMatch array after the Invalid Input: text.

Your code so far

function getCaloriesFromInputs(list) {
  let calories = 0;

  for (let i = 0; i < list.length; i++) {
    const currVal = cleanInputString(list[i].value);
    const invalidInputMatch = isInvalidInput(currVal);

    if (invalidInputMatch) {
      alert(`Invalid Input: ${invalidInputMatch[0].value}`);
    }
  }
}

Your browser information:

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

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 61

Ya, the hint is very misleading. It’s implying you aren’t using a template literal when you are. Bad hint!

The issue is how you are accessing the value in invalidInputMatch. What types of values are in that array? How would you access them?

2 Likes

Yup that was it… i was using .value for no reason at all.
Thank you!

1 Like