Change variable value Error



On line 7 you need to change the value of myName to the first two letters of your name ..

myName  = "je";


It wants you to use only javascript to change the display to the first two letters of your name.

So var myName = "Jeff" is creating a variable called myName which is equal to "Jeff"

console.log(myName); is calling up that variable and printing its value to the console.

Now, at this point, you want to change the value of the varable called myName to just the first 2 letters of your name. To do this you need to use the following code: myName = myName.substring(0, 2);

This code does a couple things: it calls up the variable named myName, which is equal to "Jeff" and then uses substring to take the characters in the first (0) position and second (1) position and then cut off at third (2) position so that you end up with just "Je".

Because of the numbering system on the substring 0=J, 1=E, 2=F and 3=F.

Then you just print the results to the console with console.log(myName) again and you got it.


// On line 2, declare a variable myName and give it your name.
var myName = "jeff";

console.log ( myName );

// On line 7, change the value of myName to be just the first 2
var myName = myName.substring(0,2);

console.log ( myName )

Should look like this