Bracket Notation Help

I’m working on this question, and I feel like my answer was right but it would not let me pass to the next level. Here is the example:

// Setup
const lastName = “Lovelace”;

// Only change code below this line
const thirdLetterOfLastName = lastName; // Change this line

If the computers start counting at 0 , that would mean that the first character is actually the zeroth character. This example is asking for the third letter of the last name. If the last name is LoveLace, it would have to be the letter ‘e’ that’s in the 3rd place, right?

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Use Bracket Notation to Find the Nth Character in a String

Link to the challenge:

The third letter is ‘v’. And this letter at index 2.

L o v e L a c e
0 1 2 3 4 5 6 7 
1 Like

You’re conflating array indexing with normal counting. In JS, characters in a string can be accessed using array indexing, which does start at 0. But that doesn’t mean that the first character in the string isn’t the “first” character in the string. It is. So the third character in this string is “v” but you would access with JS array indexing using 2.


I am afraid you misunderstood the concept of how an array is indexed in Javascript. Actually, the index numbers indicate the offset of the current element compared to the first one. In this case, if you want to search for the third letter in the array, you should count how far the current letter is away from the first one ‘L’: 0->1->2. So the index number for the third letter should be 2.