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

Tell us what’s happening:
Describe your issue in detail here.
Now, How i use bracket notation here, because if i put v in bracket it is not working.
Your code so far

// Setup
const lastName = "Lovelace";

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

Your browser information:

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

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

Link to the challenge:

Hello again,

You are just adding the letter itself…this is not how it is supposed to be done. Look at the example the challenge gives you. This should help in figuring out what you need to do

The example is

const firstName = "Ada";
const secondLetterOfFirstName = firstName[1];

Here you can see Ada is the firstName variable, and the secondLetterOfFirstName is using firstName[1]. This means that the letter d is going to be the value of the variable. Because counting starts at 0.

i check ed the example but i am not figuring out it.I did not understand the real meaning of guidline.

So here is the example again

const firstName = "Ada";
const secondLetterOfFirstName = firstName[1];

Here you can see Ada is the firstName variable, and the secondLetterOfFirstName is using firstName[1]. This means that the letter d is going to be the value of the variable. Because counting starts at 0.

Does this at least make sense?


then my this code not fulfil the first test.

Its going to fail because you are not using the right number. Remember counting starts at 0 and you need the number that represents v. So when you use lastName[1] you are getting the o

start counting at 0 so l is going to be 0,
o is going to be 1
continue from there

thankyou again it worked.

1 Like

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