Learn Form Validation by Building a Calorie Counter - Step 22

Tell us what’s happening:

Step 22: I’m really stuck on this step and have tried many things. I’ve done google searches, I’ve taken a break and stepped away. I’m not even sure what my question is or what I’m not understanding. Is anyone able to explain what I need to do or point me in the right direction?

Within your loop, you need to check if the character in strArray at index i is not a + , - , or a space. If it is not, push it to the cleanStrArray .

Your code so far

This is one option I’ve tried. I’ve also tried using ! in multiple different locations. Everything I’ve tried results in " Your for loop should have an if statement."

for (let i = 0; ![“+”, “-”, " “].includes(); i++) {
if (!(strArray[i].includes[”+", “-”, " "])) {


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.

function cleanInputString(str) {
  const strArray = str.split('');
  const cleanStrArray = [];
  for (let i = 0; !["+", "-", " "].includes(); i++) {
      if (!(strArray[i].includes["+", "-", " "])) {

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 22

You have a couple of issues.

You should not alter the for loop at all.
Please reset the lesson and not touch the for loop.

Then inside the for loop is where you add your if statement.

The issue here is that you have these switched

You need to check if the current character strArray[i] is not in the ["+", "-", " "]
Not the other way around.

just like the example they gave here

 if (!['a', 'e', 'i', 'o', 'u'].includes(charArray[i])) {

This example is checking if the current character in the charArray is not included in the array of vowels.

You need to do the same thing in this step.

once you fix those things, then it will pass :+1:

Thank you so much!!! It works now. Since I had altered the for loop, it now makes sense why none of the options I tried did worked (and never would work).