26 Change variable values


#1

What am I doing wrong here?

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


#2

console.log= myName;

This line, actually ruins the whole program. :sweat_smile:

Unfortunately you're going to have to refresh your browser for anything to work, however first, you'll need to change that line to this:

console.log(myName);

After you change them both to that line go ahead and refresh your browser, this will reset the script and allow you to pass the lesson.

Lastly, when you're using a variable you cannot declare it twice,

var myName = "Ajayi";

This line declares the variable myName, so for the rest of the program this variable can be used. When you've already declared a variable you basically do the same things to change the variable, except you get rid of "var"

myName = myName.substring(0,2);

Otherwise your code looks good!


#3

Lol. Thanks for your help!