Learn Form Validation by Building a Calorie Counter - Step 57

Tell us what’s happening:

i tried currVal = list[i], and every other variation i know to assign the value of the element in list at index i to a variable called currVal , but i can’t get it.
Pls help.

Your code so far

function getCaloriesFromInputs(list) {
  let calories = 0;

  for (let i = 0; i < list.length; i++) {
    currVal = list[i];
  }
}

Your browser information:

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

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 57

Don’t forget to declare the variable

i tried const and let, doesn’t work, i even tried to declare it before the loop , but idk

What’s your code where you include a variable declaration?

This is an object, so make sure to access the value property

btw thx for taking the time to help me that very nice from you.

i declared it like this

function getCaloriesFromInputs(list) {
  let calories = 0;

  for (let i = 0; i < list.length; i++) {
    const currVal = list[i];
  }
}

or
let currVal = list[i];

or

function getCaloriesFromInputs(list) {
  let calories = 0;
 const currVal;
  for (let i = 0; i < list.length; i++) {
     currVal = list[i];
  }
}

The first declaration looks good. Don’t forget to add this

i tried this even if it doesn’t make sense to me
i’m lost,
i tried on it another browser to check if any extension was responsible either, but no so idk

don’t mind the [] in the param
just trying everything at this point

I don’t see you accessing the value property. The list holds a bunch of objects.

y i’m blind thank you for insisting, i thought i tried it before, but i did not apprently.

thx a lot

for other that may be blind like me, you need a value somewhere in that code.

1 Like

Everyone gets stuck from time to time

1 Like

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