New to this, trying to learn the basic and understand it

Tell us what’s happening:
Describe your issue in detail here.
Im still new to this and im trying to understand why or how it works
so this part
const secondToLastLetterOfLastName = lastName[lastName.length - 2};
this was the answer but , if i try to change second to third and -2 to -3, it wont work, is there a reason why?> trying to understand it. Thanks

Your code so far

// Setup
const lastName = "Lovelace";

// Only change code below this line
const secondToLastLetterOfLastName = lastName; // 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/ Safari/537.36

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

Link to the challenge:

because the challenge wants a variable named secondToLastLetterOfLastName

the variable name itself doesn’t have any specific meaning for JavaScript, it’s just a bunch of characters put together to identify a value

so if you use the variable thirdToLastLetterOfLastName that will be a completely different variable which is not recognised by the code used to test this challenge

Ohh i see, the way i thinking it was that i knew is a variable, but if i was trying something else it didnt work, but if its based on the challenge then yeaa makes sence. thanks

you can test what is the value of a variable using console.log
for example, like this:

const lastName = "Lovelace";

const thirdToLastLetterOfLastName = lastName[lastName.length - 3];


you will see in the console the value of thirdToLastLetterOfLastName

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