How the variable should have the value of v

The thirdLetterOfLastName variable should have the value of v .
i write v between bracket notation but not working after lastname

Your code so far

// Setup
var lastName = "Lovelace";
var thirdLetterOfLastName = lastName [v];

Your browser information:

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

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

Link to the challenge:

this the link

The lesson is asking you to use the bracket notation to return the value "v" , which is a string character, by using it’s index number.

var thirdLetterOfLastName = lastName [v];

is not going to work because that is saying
you want the value at index v. Also you have a typo in the bracket notation, an extra character, (hint: it might be an “invisible” character).

There is no index v, you need to use the index number of the string where v is located.

Remember that javascript is a zero indexed language, meaning indexes start at 0, not 1.

yes s true thanks man

it would work if you add var v=2, which is the index number in the lastName string, which corresponds with “v”. That way lastName[v] would look for the index value your variable v has. Notice how when you simply put v, JS looks for a variable named that way

1 Like

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