Need help in explaining for length

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

let lastNameLength = lastName.length;

Your browser information:

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

Challenge: Find the Length of a String

Link to the challenge:

Hi Jaexus

Are you looking for further explanations of how a strings length is determined?

Or is this code giving you an error?

I got an error running the code for reusing a variables name. Using unique variable names would fix that.

You try to redeclare the variable, when you want to reassign it’s value

I get this error when I run that code

Uncaught SyntaxError: Identifier 'lastNameLength' has already been declared

let lastNameLength = 0;

// ...

let lastNameLength = lastName.length;

If your updating the value, just drop the second let keyword, it only needs to be declared once.

let lastNameLength = 0;

// ...

lastNameLength = lastName.length;

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