Getting started with Programming


#1

I keep getting errors saying my syntax is wrong. What am I doing wrong?

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


#2

On all of your console.logs.

Since myName is a variable you do not need the qoutes.

Your literally printing out myName to the console, you want to print out "Anne" though :slightly_smiling: .

console.log(myName);
console.log(myName.substring(0,2));

Hope that helps :sunny:


#3

It just says my syntax is wrong. If I take away the " ", it doesn't like that and tells me to define it.
Here is a screen shot:


#4

OMG! I just figured it out after about 2 hrs! The syntax problem was the very last ). That's all!
Thanks for helping!


#5

Woot :slightly_smiling: . You do understand that you could replace console.log("Anne"); with console.log(myName); ?

Because myName is storing "Anne" so you can just use it to refer to "Anne" :sunny:

Anyways, good job!


#6

Yes, I do understand that too! Thanks!