Tell us what’s happening:
Hello, I’m trying to understand why in this “for” loop we check if strArray[i] has +, - or " "? Shouldn’t it be to check if strArray has it? why do we need the “[i]” if “i” is only a varieble we made for the loop to star, check a condition and stop? I’m confused and can’t seem to find an answer…
Your for
loop should see if strArray[i]
is found in ["+", "-", " "]
Your code so far
function cleanInputString(str) {
const strArray = str.split(‘’);
const cleanStrArray = ;
for (let i = 0; i < strArray.length; i++) {
if (![“+”, “-”, " "].includes(strArray));
}
}
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 Edg/120.0.0.0
Challenge Information:
Learn Form Validation by Building a Calorie Counter - Step 22