Find the Length of a String225

Find the Length of a String225
0.0 0

#1

Tell us what’s happening:

it does not work

Your code so far


// Example
var firstNameLength = 0;
var firstName = "Ada";

firstNameLength = firstName.length;

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

// Only change code below this line.
var lastName='RenoMorr';
lastNameLength = lastName; 

lastNameLength.length;


Your browser information:

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

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


#2

You did not follow the instructions. You are supposed to assign the length of lastName to the variable named lastNameLength.

You have written a line which has the length, but you must do the assignment.


#3

Hi camper , why you changed lasteName to another value , and in the test they don’t say to you do that ,
you have to let it as it is , what you should do is to count the length of it ,
the length retuns the number of how much letters they are in the string ex:

let str="Hello";
let  howMuch=str.length;\\ expected output is 5 because it starts counting from 1 ,it is one based index
let resutlt=howMuch; \\here I assigned the variable howMuch to result so result have now value  **5** in it ;

#4

It is mind boggling for me to even grasp what is needed…I did lessons before fast…but this one i cant grasp the concept…
This .length command…
I just dont get it if you can see that the name is lets say 8 characters…why you need to display it?
THe result should be 8…should I use var and use name with 8 characters?

So in the example on that page

// Example
var firstNameLength = 0;
var firstName = “Ada”;

firstNameLength = firstName.length;

result is 3? firstNameLength is = to the number of characters in the name ADA
But above line var firstNameLength = 0; completely destroys my logic…it is set to 0 so how can it be 3 later on?


#5

Solved it is so easy…but I overcomplicated the whole thing