Learn Form Validation by Building a Calorie Counter - Step 21

Well, nothing. I typed the for loop, but it doesn’t seem to be recognizing its existence. I tried it a few ways… am I misunderstanding it?

Console returns this same message every time: // running tests Your for loop should initialize a variable called i to 0 . Your for loop should have a condition that checks if i is less than the length of strArray . Your for loop should increment i by 1 each time it runs. Use the increment operator for this. // tests completed

Your code so far

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.



  for (i = 0; i < strArray.length; i++ ) {
     }

function cleanInputString(str) {
  const strArray = str.split('');
  const cleanStrArray = [];
  for (i = 0; i < strArray.length; i++ ) {

    return cleanStrArray;
  }
  
}

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

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 21

Hello.
i should be declared using the let keyword. Also, get rid of the second for loop.

to initialize a variable you need to use let (or const but that’s should not be used here)

okay, thanks both of you. I feel dumb.

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