-
-
Save codecademydev/7e17e8216a71d642b05fbc49128aa395 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