I can't pass this challenge please help with correction

I can't pass this challenge please help with correction
0

#1

Below is my code: please what is wrong with the code!

var lastNameLength = 8;
var lastName = "elamin";
lastNameLength = lastName.length;

#2

What is the url of the challenge?


#3

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a 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.


#4

This is the url of the challenge below
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/find-the-length-of-a-string


#5

You need to use the .length property of strings. You don’t assign the length of the string, the length of string is generated once you create the string.


#6

Please help with correct code I really stuck!


#7
// Example
var firstNameLength = 0;
var firstName = "Ada";

firstNameLength = firstName.length;
///outputs: 3

I think you should start over. Then, look at the example and try to figure out what you need. You don’t need much and only need to add one word and a period.


#8

This is the code:
var lastNameLength = 8;
var lastName= “elamin”;
lastNameLength = lastName.Length;

But it’s showing
lastNameLength should be equal to eight.


#9

You weren’t supposed to change var lastName or any of the vars for that matter. Trust me when I say start over.


#10

Or if you’re hesitant to hit the reset button:

// Example
var firstNameLength = 0;
var firstName = "Ada";

firstNameLength = firstName.length;

// Setup
var lastNameLength = 0;
var lastName = "Lovelace";

// Only change code below this line.

lastNameLength = lastName;



#11

I have start over but it’s still say lastNameLength should be equal to eight. below is the code:

// Example
var firstNameLength = 0;
var firstName = “Ada”;

firstNameLength = firstName.length;

// Setup
var lastNameLength = 0;
var lastName = “Lovelace”;

// Only change code below this line.
var lastNameLength = 8;
var lastName = “Ada”;

lastNameLength = lastName.length;


#12

Remember what I said? Starting from the very beginning, the only thing you have to do is add one word and a period and you will be done.

You don’t need to add other variables, they are already set up for you.

Let me see if I can walk through the example:

var firstNameLength is initiallized to 0;
var firstName is equal to “Ada”
Now we are taking firstName and accessing the .length property of strings (because firstName holds a string value). This is done by firstName.length and by doing this we will get the length of the string, as a number, that is stored in firstName.
Then we put that value into firstNameLength.


#13

Please edit your last post and use 3 backticks on the line before and the line after your code, so that it properly formats in your post. I gave you the instructions in my second reply to this thread.

Thank you.


#14

Thank you a lot, I have passed the challenge.