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:
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/220.127.116.11 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
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