Change Variable values


#1


Hey!
I'm very new at programming and I don't understand why I always have to log my real name. I thought that the line
var myName = Larissa
is for the computer to know or rather remember my name so that I can use the variable "myName" instead of my name ...?!
I would be very happy about an explanation because I think I'm doing something wrong!


https://www.codecademy.com/en/courses/getting-started-v2/4/3?curriculum_id=506324b3a7dffd00020bf661


// On line 2, declare a variable myName and give it your name.
var myName="Larissa"
// On line 4, use console.log to print out the myName variable.
console.log("Larissa");
// On line 7, change the value of myName to be just the first 2 
// letters of your name.
console.log("Larissa".substring(0,2));
// On line 9, use console.log to print out the myName variable.
console.log("Larissa");


#2

HI you right

I thought that the line
var myName = Larissa

SO this line

console.log("Larissa");

where you put "Larissa" remove it and put myName without the " "
do the same here

console.log("Larissa".substring(0,2));

AND

// On line 7, change the value of myName to be just the first 2 
// letters of your name.

they ske you to change the value of myName so this part

console.log("Larissa".substring(0,2));

change it to

var myName = "Larissa".substring(0,2)

Of corse where you have your name you can change it with myName

var myName = myName.substring(0,2)

the last line

// On line 9, use console.log to print out the myName variable.
console.log("Larissa");

instead of "Larissa" you should print the new value of myName like that

// On line 9, use console.log to print out the myName variable.
console.log(myName);

#3

var myName="Larissa" You also need to end the sentence with a semicolon

like this :var myName = "Larissa";


#4

Thank you for the fast and detailed reply!!
You helped me a lot and now it all makes sense.


#5

hey Larrisa

I think there is some glitch with the line number 2. the way you made it it should be the right one but for some reason its not
Please let me know if you figure it out.


#6

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