Learn Form Validation by Building a Calorie Counter - Step 22

Tell us what’s happening:

Your code so far


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.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

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

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 22

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

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

Code doesn’t work

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

It looks like you have a few syntax errors

Firstly, you are missing the if statement here

Once you resolve the syntax errors, then you need to look at this part there

the directions want you to check for the current character in the strArray.
Not the entire strArray.

Pay close attention to the hint text it gives you here to fix that

Your for loop should see if strArray[i] is found in ["+", "-", " "].

Lastly, you need to fix this part here

right now you are not pushing anything to the cleanStrArray.

You need to push the current character from the strArray.

once you fix those things, then it will pass