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

The lesson is find the last letter of the string. my input looks correct… Can anyone spot my error?

Thanks

Your code so far

// Setup
const lastName = "Lovelace";

// Only change code below this line
const lastLetterOfLastName = lastName;
 var lastLetterOfLastName = [lastName.length - 1];// 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/107.0.0.0 Safari/537.36

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

Link to the challenge:

The 2nd line of code does nothing useful. It redeclares the lastLetterOfLastName as a var (why?) and then it finds the length of the lastName and subtracts one from it then sticks it in an array?

Meanwhile they provided the line of code that you were meant to modify:

const lastLetterOfLastName = lastName;

The example you were meant to use to modify this line was:

const lastLetter = firstName[firstName.length - 1];

I would reset the code and try to change the line given to me to look like the example.

Ok thanks you so my issue was the second line. Thank you very much.

1 Like