Basic JavaScript - Find the Length of a String

**Tell us what’s happening:**lastNameLength = lastName.lenght;
lastNameLength = 8;
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;

Your browser information:

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

Challenge: Basic JavaScript - Find the Length of a String

Link to the challenge:

Hi there and welcome to our community!

This is the starter code for this challenge. So, you need to edit only the last line of the code, to find out the length of the variable lastName. You use the length property to do this, as described in the challenge description and examples given.

If you try to explicitly set the value of lastNameLength to 8, your code will not pass. This is because lastNameLength should dynamically change its value depending on what string value is assigned to lastName. So, if lastName were reassigned with a value ‘Expertcoder’, for instance, then the value of lastNameLength would change accordingly from 8 to 11, without you needing to manually reassign that too.

This is the purpose of a property like length.

1 Like

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