Stuck 26 Change variable values, help please


#1

What is wrong with my code?

// On line 2, declare a variable myName and give it your name.
console.log(myName = "Barbara");
// 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("Barbara".substring(0,2));
// On line 9, use console.log to print out the myName variable.
console.log(myName);


#2

You don't set a variable inside of a console.log(). Set the variable before the log statement, and then log the variable itself.

console.log(myName);

#3

I did that but isnĀ“t working


#4

Please post your updated code and what error you are getting.


#5

I have tried quite a few combinations but nothing works.

// On line 2, declare a variable myName and give it your name.
var myName = "Barbara";
// 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.
var myName = "Ba"
// On line 9, use console.log to print out the myName variable.
console.log (myName)


#6

line 2 looks correct now!

line 4: myName is a variable, but "myName" is a string!

line 7: var creates a variable. Because myName has already been declared as a variable in line2, you can remove var from line 7.


#7

thanks this solved it


#8