Mini linter string.lenth

Hi all,
I’m having a problem with the mini linter js project, specifically step 2 which asks us to log the length of an array. I have created an array of individual words, as requested in step 1 using the following code:
const storyWords = [
story.split(’ ')


Then log the length with the following code:

My problem is that the length of storyWords returns 1, despite the fact that if i simply log the array storyWords, all of the words in the storry appear in the array. I know there is more than 1 word in the array, so why is .length returning 1?
Here’s the full code:

Any help would be greatly appreciated!

You are accidentally creating an array inside of an array: The .split() method returns an array, so you can simply set storyWords equal to story.split(' '), instead of placing it inside of an array.

In its current form, storyWords does only have length 1, because it only has one index: The resultant array of story.split(' ')


Oh,thanks! I feel kinda dull for not catching that myself. Any advice for catching things like that in the future? JS can be hard!

1 Like