- CONSIDERING STARTING FROM 0, WHY WOULDNT THE CODE BELOW BE EQUAL TO “C”
- PLEASE help
var firstName = "Ada";
var thirdToLastLetterOfFirstName = firstName[firstName.length - 3];
var lastName = "Lovelace";
// Only change code below this line
var secondToLastLetterOfLastName = lastName;
var secondToLastLetterOfFLastName= lastName[lastName.length-2];
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.
See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (
</>) will also add backticks around text.
Note: Backticks are not single quotes.
var secondToLastLetterOfFLastName= lastName[lastName.length-2]; would create a variable named secondToLastLetterOfLastName and assign
"c" to it. If you are encountering errors, it is probably because you declare
And the second time the variable is spelled wrong, so the test suit is just reading
lastName as what you are passing as value to that variable