Mini Linter step 1 - a space between the quote marks

I’ve been stuck in this exercise and I don’t think I’m ready for such complexity. I thought I had the first step completed, but then I logged to the console the result and I get the number of letters instead of words. I’ve been searching around in the forum, and everybody seems to have the same answer I wrote… why do they get a different result? I don’t know!
Then I realized they all have a space between the quotation marks inside the round brakets!

let storyWords = story.split('');
console.log(storyWords.length);

// you get the total number of letters

let storyWords = story.split(' ');
console.log(storyWords.length);

// you get the total number of words

why this happens? is there a rule to keep in mind?

Hey @css7503426086
the split method splits a string where it finds the divider you defined between the quote marks in the .split() method. If you have a space between them, it splits where it finds the space.
For example:

let string = 'This is a sentence+with+sepecial-characters';
let first = string.split('+'); // ["This is a sentence", "with", "sepecial-characters"]
let second = string.split('-'); // ["This is a sentence+with+sepecial", "characters"]
let third = string.split(' '); // ["This", "is", "a", "sentence+with+sepecial-characters"]
1 Like

thanks a lot! this had a simple explanation for a change! :crazy_face: