Basic JavaScript - Find the Length of a String

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

can anyone kindly help a begginer?

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

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

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:

You should be receiving a message about a syntax error here. You have a typo.

It doesn’t actually throw any errors. It just gives you undefined for the property that doesn’t exist.

It is such a common typo as well.

Rude, I would expect something more obvious.

1 Like

It is a feature, not a bug.

TypeScript would definitely yell at you, and it even has a helpful error message.

Property ‘lenght’ does not exist on type ‘“Lovelace”’. Did you mean ‘length’?

Yeah, I understand why its there and how it’s baked into JS deeply - I just don’t like it :slight_smile:

I’m used to the beautiful world of compiled languages, lol

JS doing JS things, what can you do? But I agree, it isn’t very helpful in this case.

Well, until you have to wait 4 hours for a compilation. Then it starts to get old pretty fast.

1 Like

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