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

Wednesday, December 5, 2012

Codecademy: Codeyear Prototyping Fun


//sample solution


// recreate your Candy class here
function Candy(name){
this.name = name;
};

// extend the prototype of Candy with a "printName" method
Candy.prototype.printName = function(){
console.log(this.name);
};

// testing code for your method
var chocolate = new Candy("chocolate");
chocolate.printName();

var gummyBears = new Candy("gummy bears");
gummyBears.printName();

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts