Basic JavaScript - Find the Length of a String

Hi, i am block here.
Someone could help me please ?

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

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Find the Length of a String

Link to the challenge:

never wrap your variable name in quote marks

// Setup

let lastNameLength = 0;

const lastName = "Lovelace";

// Only change code below this line

lastNameLength = lastName;

console.log("lastName".length);

i’ve done this but not workin

Look at this line here: console.log("lastName".length);

Why did you but the name of the variable in quotes?

And this line: lastNameLength = lastName;

This is the line that you want to change. Currently, it is setting lastNameLength to equal “Lovelace”. Take a look at the explanation on the left side of the exercise to see how to find the length of a string called firstName.

For example, if we created a variable
const variableName = "Ada" ,
we could find out how long the string Ada is by using the
variableName.length
property.

Thanks for your help !

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

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

I've done this and the result is 8 but it seems to be incorrect

Now you have output the correct answer to the console, but you need to assign that value to the lastNameLength variable. Put what you entered into console.log(...) after lastNameLength = .

1 Like

Thanks a lot ! It’s clear !

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