Basic JavaScript - Find the Length of a String

Tell us what’s happening:
Not sure what’s going wrong. I am getting the value of 8 in the console like it states.

This is the code after everything is reset.
Your code so far

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

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

Heres the code after edit

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

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

> // running tests

lastNameLength


should be equal to eight. You should be getting the length of

lastName


by using

.length


like this:

lastName.length


. // tests completed // console output 8 8

**Challenge:**  Basic JavaScript - Find the Length of a String

**Link to the challenge:**
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/find-the-length-of-a-string

You need to assign the length of lastName to the variable lastNameLength. Your current code assigns the value of lastName to the variable lastNameLength.

I’m confused. The first sentence looks exactly the same as the second sentence or I have just been staring at this too long.

You need to assign the length of lastName to the variable lastNameLength. Your current code assigns the value of lastName to the variable lastNameLength.

You need to change this line:

lastNameLength = lastName;

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