-
-
Save codecademydev/58fd5b2852a42c86bad8f00b7aba4e42 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// original classes | |
function Animal(name, numLegs) { | |
this.name = name; | |
this.numLegs = numLegs; | |
this.isAlive = true; | |
} | |
function Penguin(name) { | |
this.name = name; | |
this.numLegs = 2; | |
} | |
function Emperor(name) { | |
this.name = name; | |
this.saying = "Waddle waddle"; | |
} | |
// set up the prototype chain | |
Penguin.prototype = new Animal(); | |
Emperor.prototype = new Penguin(); | |
var myEmperor = new Emperor("Jules"); | |
console.log( myEmperor.saying ); // should print "Waddle waddle" | |
console.log(myEmperor.numLegs ); // should print 2 | |
console.log(myEmperor.isAlive ); // should print true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment