Basic JavaScript - Use Bracket Notation to Find the Nth Character in a String

Tell us what’s happening:
Describe your issue in detail here.

What is wrong with my code? The “v” is the 3rd letter in the word…

// Setup
const lastName = "Lovelace";

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0

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

Link to the challenge:

I would suggest adding a conosle.log so you can see which letter your code is returning

console.log(thirdLetterOfLastName)

Remember that computers start counting at 0

hope that helps

Zero-based indexing. The index numbers begin at zero whether you’re working with strings, arrays or many other forms of data in Javascript.
So, for instance:

let name = "igorgetmeabrain"
console.log(name[0])

This would print ‘i’ to the console, as it’s the first letter of name.

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