Why am I getting it wrong?

Tell us what’s happening:
The output is 8, but its still marked as an error. any help?

Your code so far


// Setup
var lastNameLength = 0;
var lastName = "Lovelace";

// Only change code below this line

lastNameLength = 8;
console.log(lastName.length);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Safari/605.1.15

Challenge: Find the Length of a String

Link to the challenge:

Hi @GoodNGo !

You are not supposed to hard code the number 8 here.

The goal of the challenge is to use the length property.

You are supposed to assign the length of lastName to lastNameLength.

Take this part

and assign it to the variable

1 Like

one more question, in this exercise https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-first-character-in-a-string I am getting an error for “You should use bracket notation.” here’s my code var firstLetterOfLastName = "L"; var lastName = lastName[0];

Whenever you have a new challenge you should always open up a new topic using the Ask for help button. :grinning:

It is bad practice on the forum to have multiple challenge discussions in the same topic.

Since the topic is about Find the Length of a String, it is best not to add in other challenges into this discussion.

1 Like

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