Basic JavaScript - Find the Length of a String

i keep getting an error. i don’t know what is wrong here

Your code so far

// Setup
let lastNameLength = 0;
const lastName = "Lovelace";

// Only change code below this line
lastNameLength = lastName;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic JavaScript - Find the Length of a String

Link to the challenge:

1 Like

Does this line make sense? You’re saying, in words, that the length of the string is the string itself.

1 Like

Hello, Baone.

You set the value of the required variable to the string itself not the length of the string.

" Use the .length property to set lastNameLength to the number of characters in lastName . "

in your code you set `lastNameLength = lastName´

The exercise wants you to set the value of lastNameLength “to the number of characters in last name” so:

You are printing the numbers of characters in console.log(lastName.length);

But in your code the value of lastNameLength is “Lovelace” and not the numbers of characters in said string.

I hope to have helped you,if not just say anything and ill try again.

1 Like

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

1 Like

Thank you for editing for me and i’m sorry for infringing the rules.
Whenever i’m able to help someone, i won’t post the solution again .
Have a nice day :slight_smile:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.