Iterating through an array

I’m trying to iterate through an array an then trying to get the length but my code isn’t working. Why can’t get get the length?

var str = "The quick brown fox";
str = str.split(' ')

for (var i=0; i < str.length; i++) {
   console.log(str[i]);
   str[i].length()
}

TIA,

Gabriel

The semi-colon is missing in the end of str[i].length; in the for loop.
Same at the begining, str = str.split(’ '); .

Remove round brackets in this line:
str[i].length() should be str[i].length

1 Like

It’s totally fine to omit semicolons. https://standardjs.com/rules.html#semicolons

I added the semi-colon and it still doesn’t work.

After you split your array, look at the output: console.log(str);

And think how would you enumerate each content of the array.

GL!