Learn Form Validation by Building a Calorie Counter - Step 22

Tell us what’s happening:

I’m getting an error that says im not using ![“+”, “-”, “”].includes() in my code. The code is supposed to check to see if there is any of those strings in the array and if not is pushes the string onto the clearStrArray. Can anyone tell me what I’m missing please?

Your code so far

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

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

    }
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 OPR/105.0.0.0 (Edition std-1)

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 22

Hey @BryanSHANG, and welcome to the FCC Community!

There are a couple problems here.

  1. The array itself

Check this line closely. I don’t want to give it away but there’s something strange in that array. One of those strings is not what it should be…

  1. Although you can use a variable here, the challenge does not want you to use a variable to hold the value of strArray[i], so you’ll have to go back to just using strArray[i] instead of character.
1 Like

haha thank you I figured it out the " ", The main issue I was having was with the strArray[i] I was really overthinking that one!

thanks again and I’m glad to be here!

1 Like

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