Javascript: Change Variable Values--What's wrong with this code?


#1

// On line 2, declare a variable myName and give it your name.
var myName= "Joe";
// 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.
myName="Joe".substring(0,3)

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


#2

Change this to

myName = ("Joe".substring(0,2));

#3

Thanks for your help! I'm still getting an error, even with the correction ! It says "Oops, try again. It looks like you didn't log your whole name to the console."

Thank you !!


#4

I don't know how I missed that. You don't need to use an equals (=) sign for console.log() because of the brackets. Syntax is as follows:

console.log();

#5

That did the job, thank you so much!


#6

I'm glad I could help. Could you please mark this topic as complete now by clicking the tick box button under my post?
Thanks,
JibblyJ.