Basic JavaScript - Find the Length of a String

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

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

// Only change code below this line
lastNameLength = 8;
console.log(lastName.length)

Your browser information:

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

Challenge: Basic JavaScript - Find the Length of a String

Link to the challenge:

Welcome to the forum!

Could you try to explain in your own words what you don’t understand about this challenge please? The more you say, the more we can help.

for finding a string length I used the ".length " property and it just says some

You have logged the length of lastName to the console but, to pass the challenge, you should be assigning it to the variable lastNameLength, using the .length property.

This means that whatever string is assigned to lastName, the value of lastNameLength will always be correct.

how. could please just elaborate on this.

Instead of assigning the value 8 explicitly to lastNameLength, assign the length of lastName, using the .length property.

1 Like

What you should do is to solve it this way.

MOD EDIT: Solution removed.

In the question, it was asked that the lastNameLength length should be eight and we have to print the lastName.length.
In the above code, we’ve got the output off lastNameLength as eight and we’ve logged the lastName.length as well.

Please do not post working solutions on the forum. We are here to offer advice and hints, not solutions.

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