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

Your browser information:

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

Challenge: Basic JavaScript - Find the Length of a String

Link to the challenge:

Don’t add any extra lines of code. I would reset the lesson to get the original JS back. The original code sets the variable lastNameLength to the string stored in lastName. You want to set it to the length of the string stored in lastName. You use the .length property to do that.

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

You didn’t set the ‘length’ property on the ‘lastNameLength’ variable in order to get the number of letters. Apply the .length property on the ‘lastName’ variable and assign the result to the ‘lastNameLength’, then print the result in the console by using the ‘log’ method on the ‘lastNameLength’ variable:

longerVariable = shorterVariable.property
console.log(longerVariable)

This is guidance.

1 Like

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