Mini Linter Step 5

Hi everyone,

Here is my question and hope someone can help me. I’ve done a lot of research, but I still don’t understand how the following program works? Why use.length-1 ? Thank you!

Exercise:
https://www.codecademy.com/courses/introduction-to-javascript/projects/mini-linter

Task:
Step 5, count how many sentences are in the paragraph.

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

I’ve read this:

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