Tell us what’s happening:
this is my code. I am stumped. can you please help me get the answer.
Your code so far
// Example
var firstName = “Ada”;
var lastLetterOfFirstName = firstName[firstName.length - 1];
// Setup
var lastName = “Lovelace”;
// Only change code below this line.
var lastLetterOfLastName = lastName[lastName.length - 1];
console.log(lastLetterofLastName);
// Example
var firstName = "Ada";
var lastLetterOfFirstName = firstName[firstName.length - 1];
// Setup
var lastName = "Lovelace";
// Only change code below this line.
var lastLetterOfLastName = lastName[lastName.length - 1];
console.log(lastLetterofLastName);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36
.
Challenge: Use Bracket Notation to Find the Last Character in a String
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-last-character-in-a-string
ReferenceError: lastLetterofLastName is not defined
That’s odd, isn’t it? Seems like you have to create that variable… I would definitely take a look at the variables that you’ve made and check to see if they are spelled properly!
Best of luck!
Do I have to ass the string property? I am confused by the “defined” part.
use* I apologize
this is just some extra characters
When you define a variable you will specify the type and then the variable name.
var ImAVariable = 1;
const ImAlsoAVariable = "Hello";
let ITooAmAVariable = "I'm a variable!";
console.log(NonExistingVariable)
You can see that I’ve defined the variables ImAVariable
, ImAlsoAVariable
, and ITooAmAVariable
. When I try to console.log()
a variable that I haven’t created it lets us know that the variable hasn’t been defined. In our case here,
ReferenceError: lastLetterofLastName is not defined
You have no created the variable lastLetterofLastName
. It’s important to remember that variable names are case sensitive.
var variable = 2;
var VARIABLE = 3;
These are considered two different variables.
I hope this brings you closer to a solution. Feel free to continue asking if you need further assistance.
You have a typo.
You declared the variable lastLetterOfLastName
but then you attempted to log the variable lastLetterofLastName
. Because these variable names are not exactly the same, you are getting an error that lastLetterofLastName
is not defined.