Change variable values


#1



No idea whats wrong :frowning: please help


Replace this line with your code. 

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


#2

The above is an assignment and as such whatever console.log was before, it is no longer that, but "Tint". You'll need to refresh your browser to restore the .log() method.

Correct your code before you run it, or you will overwrite that built-in function, again.

console.log("whatever you want to print");  // printing a string literal

console.log(your_variable)                  // printing a referenced value or object

#3

sorry i still don't get it :frowning:


#4

nvm i got it... i reset the code n typed this n it works

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


#5

Bingo! Well done. You're catching on real quick!


#6

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