Learn Form Validation by Building a Calorie Counter - Step 22

Tell us what’s happening:

I’m stuck, i receive this error:
SyntaxError: unknown: Unexpected token (20:1) 18 | } 19 | > 20 | } | ^

What can I do?

Your code so far

function cleanInputString(str) {
const strArray = str.split(‘’);
const cleanStrArray = ;

for(const i=0; i<strArray.lenght; i++) {

if (!strArray.includes([‘+’, ‘-’, ’ '])){
push(cleanStrArray);
}
}

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

the syntax error is because you are missing the } that closes the function

after that you need to use push correctly:
push is used on an array: arr.push() and between the parenthesis you put the thing or things you want to add to the array: arr.push(things_to_add_to_the_array)

Besides what ilenia mentioned, there is also a typo in your for loop condition

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