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 = lastName;
console.log(lastNameLength.length);

Your browser information:

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

Challenge Information:

Basic JavaScript - Find the Length of a String

You want to set lastNameLength to the length of lastName, not to the string stored in lastName.

Hey
To get the length of a string we use the dot length method on the variable holding the string.So like in this case we get the length of last name then you assign it to variable LastNameLength.
Then you log in the variable like so

var name = "oslo";

var  stringLength =name.length;
console.log(stringLength);

Hope this helps

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