Quotes help make search much faster. Example: "Practice Makes Perfect"

Wednesday, December 5, 2012

Codecademy: Codeyear The "this" Keyword


//sample solution


var setName = function(yourName){
    this.name = "Your name is " + yourName;
};

// create an object called `human`
var human = new Object();
//make sure the human.name property is initialized
human.name = "";
//pattern the setHumanName method after the setName function
human.setHumanName = function(yourName){
this.name = "Your name is " + yourName;
};

// now call human.setHumanName
human.setHumanName("Jim");

// check to see that your method works by printing
// human.name to the console
console.log(human.name);

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts