Why does the last index use length minus one? Goal: Read the last character without using the first invalid index.
String indexes stop at length minus one.
The first invalid index is exactly the string length.
1// Goal: Read the last character without using the first invalid index.2function starterExample() {3const word = "code";4const last = word[word.length - 1];5}
Why does the last index use length minus one?