Use Bracket Notation to Find the NthtoLast Character in a String

Use Bracket Notation to Find the NthtoLast Character in a String
0

#1

Tell us what’s happening:

Your code so far

// Example
var firstName = "Ada";
var thirdToLastLetterOfFirstName = firstName[firstName.length - 3];

// Setup
var lastName = "Lovelace";

// Only change code below this line
var secondToLastLetterOfLastName = lastName[lastName.lenght-1];


Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36.

Link to the challenge:


#2

First, you have a typo at lenght. (last line)

Note that .length - 1 will always point to the last char of a string.


#3

Oh, thank you! I have same question, this helped. Now I understand.