Tell us what’s happening:
Describe your issue in detail here.
Your code so far
.length property to set
lastNameLength to the number of characters in
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 .
let lastNameLength = 0;
const lastName = "Lovelace";
// Only change code below this line
lastNameLength = lastName;
Your browser information:
User Agent is:
Mozilla/5.0 (Linux; Android 13; SM-A047F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/188.8.131.52 Mobile Safari/537.36
Link to the challenge:
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
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 )
Have a nice coding day!
I just realize this problem,passed it this Saturday.
Thank you for your help.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.