Learn Form Validation by Building a Calorie Counter - Step 22

Tell us what’s happening:

Can I get some guidance I’m not understanding why it is incorrect.

Your code so far

function cleanInputString(str) {
  const strArray = str.split('');
  const cleanStrArray = [];

  for (let i = 0; i < strArray.length; i++) {
    if(!["+", "-", " "].includes(strArray[i]));{
    cleanStrArray.push(strArray[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 22

You have a semicolon ; after the if conditional part

if(!["+", "-", " "].includes(strArray[i])); <-

I have erased the semicolon however it is still showing up incorrect. Any other suggestions?

Make sure you didn’t delete something more by accident. All I have to do to make your code pass is to remove the extra semicolon. Maybe reset the challenge and try again.


Post your current code. Use the </> button on the reply box upper toolbar to format the code.

 (let i = 0; i < strArray.length; i++) {
if (!["+", "-", " "].includes(strArray[i]))
cleanStrArray.push(strArray[i])
  }

You deleted the opening bracket { on the if statement.

if (something) {
  // code
}
1 Like

thank you kindly that worked.

1 Like

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