Tell us what’s happening:
Describe your issue in detail here.
Your code so far
Use the .length property to set lastNameLength to the number of characters in lastName .
I was told to do the above instruction but i did and i can’t see to know what am getting wrong at. I have checked other forums hints but the explanations seems hard for me to understand . Can someone please explain to me in the simplest form for me to get it .
// Setup
let lastNameLength = 0;
const lastName = "Lovelace";
// Only change code below this line
lastNameLength = lastName;
console.log("lastNameLength".length)
Your browser information:
User Agent is: Mozilla/5.0 (Linux; Android 13; SM-A047F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Mobile Safari/537.36
Challenge: Basic JavaScript - Find the Length of a String
This is just setting the variable lastNameLength to the value of lastName, which is the string “Lovelace”. You want to set lastNameLength to the length of the string in lastName.
Hi Aisha! I expect this helps:
The instruction is to get the number of characters of that string. You can get it using the .length property adding it in this case to a variable ( ex. var.length ) because you can add it to a string literal too ( ex. “string literal”.length ). You need to set lastNameLength with that number.
In your console.log you are getting the number (length) of an string literal “lastNameLength”, not the variable. If you want to get the length of the variable, you need to put it without quotes console.log(lastNameLength.length)
But your variable stills in 0 because you didn’t assign it the length. The way to do it is putting the function .length with the lastName variable in the reassignment on this line:
There you assign lastNameLength ( wich is a number vaiable ) with lastName ( an string ), you need to get the length ( number ) of the string ( lastName.length )