21. Up the Food-I-mean-Prototype Chain



Oops, try again. It looks like you didn't print 2, I do not understand why

// 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(myPenguin.numLegs); // should print 2
console.log(myAnimal.isAlive); // should print true


Try myEmperor instead of myPenguin in this situation.


Oops, try again. It looks like you didn't print true,
this was the response


I figured it out thank you


Good! Glad to have helped! :smiley: If you have anymore questions you know what to do! :thumbsup:


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