Help me to finish

The thirdLetterOfLastName variable should have the value of v .

You should use bracket notation.

Your code so far

// Setup
var lastName = "Lovelace";

// Only change code below this line

var thirdLetterOfLastName = lastName[v]; // Change this line

Use Bracket Notation to Find the Nth Character in a String

Link to the challenge:

@camperbot help to solve this challenge

You need to put the correct number inside of the brackets so that thirdLetterOfLastName is assigned the third letter of lastName (which happens to be a v). You cannot use letters to index into a string in the way you are attempting.

1 Like

thank you @JeremyLT

@JeremyLT pls help still it says it’s not correct. can you comment down the solution

Remember that indexing in JavaScript is zero-based, so lastName[0] would return the first letter of the string.


@jsdisco thank you very much …

still it’s not working @jsdisco

What is your updated code?

1 Like


// Setup
var lastName = "Lovelace";

// Only change code below this line

var thirdLetterOfLastName = lastName[0]; // Change this line

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

The challenge wants you to find the third letter of the last name.

What you wrote here.

is for the first letter.

If you console.log(lastName[0]) then you will see that it returns the letter L.

Change the number in the brackets so it returns the letter v.


still, it says that it’s wrong please help me.

// Setup

var lastName = "Lovelace";

// Only change code below this line

var thirdLetterOfLastName = console.log(lastName[2]); // Change this line

You are not supposed to include the console.log in your answer.

That was just to show you what is actually being printed.

Remove that and it should pass.

1 Like

@jwilkins.oboe thank you for your help. I passed

1 Like

Hi, accessing the characters of a string/array in any programming language with bracket notation uses index. The indexing starts with 0 and in this case,

var lastName = "Lovelace";

The indices of each character would be as follows:
Character: [ ‘L’, ‘o’, ‘v’, ‘e’, ‘l’, ‘a’, ‘c’, ‘e’ ]
Indices: [ 0, 1, 2, 3, 4, 5, 6, 7 ]

When you normally count the third letter would always be at 2nd index. So your answer would be

var thirdLetterOfLastName = lastName[2];  

Hi @putta !

Welcome to the forum!

I have adding spoiler tags around your code because it is a full working answer.

On the forum, we don’t encourage users to give out full working answers but rather guide them to the correct answer with hints.

Something to keep in mind for future posts.


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