# Mini Linter JavaScript

#1

What’s wrong with sentCount ?

let story = ‘Last weekend, I took literally the most beautiful bike ride of my life. The route is called “The 9W to Nyack” and it actually stretches all the way from Riverside Park in Manhattan to South Nyack, New Jersey. It’s really an adventure from beginning to end! It is a 48 mile loop and it basically took me an entire day. I stopped at Riverbank State Park to take some extremely artsy photos. It was a short stop, though, because I had a really long way left to go. After a quick photo op at the very popular Little Red Lighthouse, I began my trek across the George Washington Bridge into New Jersey. The GW is actually very long - 4,760 feet! I was already very tired by the time I got to the other side. An hour later, I reached Greenbrook Nature Sanctuary, an extremely beautiful park along the coast of the Hudson. Something that was very surprising to me was that near the end of the route you actually cross back into New York! At this point, you are very close to the end.’;
let unnecessaryWords = [‘extremely’, ‘literally’, ‘actually’ ];
let storyWords = story.split(’ ');

let sentCount = 0;
storyWords.forEach(wor => {
if (wor === ‘.’ || wor === ‘!’) {
sentCount+=1;
console.log(sentCount);
}
});
console.log();

#2

Which step are you on? `sentCount` does not look like any variable we are prescribed to use. As for the word count, ignoring punctuation, it will be the length of `storyWords`.

#3

step 5. I see in hint
let sentences = 0;
array.forEach(word => {
if (word[word.length-1] === ‘.’ || word[word.length-1] === ‘!’) {
sentences+=1;
}
});

I do not understand meaning “.length-1” in this code.
why length-1 ?

For my logical, it can be :
if (word[word[0]] === ‘.’ || word[word[0]] === ‘!’) {
sentences+=1;
}
});

#4

Will be the character at the last index of the word.

``````word[0]
``````

will be the character at the first index of the word.

#5

Thank you for clarification. I forget that “.” and “!” last one symbol.
How can I get just 1 number?
I got in my code from 0 to 12:

9
9
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
11
11
11
11
11
11
11
11
11
11
12

#6

Using the code from the hint,

``````let sentences = 0;
array.forEach(word => {
if (word[word.length-1] === ‘.’ || word[word.length-1] === ‘!’) {
sentences+=1;
}
});
``````

all that remains is to log the final value…

``````    console.log(sentences)
``````

#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.