TTEOTM
1
Tell us what’s happening:
What’s wrong in for array loop ?
function cleanInputString(str) {
const strArray = str.split('');
const cleanStrArray = [];
for(let i=0;i<strArray.length-1;i++){
}
Console Output:
Challenge Information:
Learn Form Validation by Building a Calorie Counter - Step 21
hello! @TTEOTM
I am sorry, I am wrong!
it is length not length-1
2 Likes
TTEOTM
3
I dn’t understand …it already has i++ in :
for(let i=0;i<strArray.length-1;i++){
}
Teller
4
Hi @TTEOTM
As @Jyothsna13 pointed out to iterate though the array use the length method.
length - 1 is used to find the last item of an array.
The reason your code may not be working may be because the function is missing a closing curly bracket.
Happy coding
system
Closed
5
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.