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

Tell us what’s happening:
I try creating with the word var, let and const and I got the same mistake.

const secondToLastLetterOfLastName = lastName[lastName.lenght - 2];

say
should be the letter c
.You should use.length
to get the second last letter.

Your code so far

const lastName = "Lovelace";
const secondToLastLetterOfLastName = lastName[lastName.lenght - 2];

Your browser information:

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

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

Link to the challenge:

are you sure you wrote it correctly?

You’ve got a typo in “length”. It’s a common mistake.

perdon but your aswers doesn´t help me. I’m using
LastName[LastName.length -2]

that is different from the code you posted before.
also, you don’t have a LastName variable, it should be lastName

This is my answer.
const lastName = “Lovelace”;
const secondToLastLetterOfLastName = lastName[lastName.lenght - 2];

there’s an variable lastName right? I should get the letter c of LastName; I create new variable secondToLastLetterOf. even, use(let, var and const) and also use the meth .length but I keepeing the same mistake

now check again here, as if this is the code in your editor, it will not work for the issue pointed out in previous posts

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