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


#1


https://www.codecademy.com/en/courses/objects-ii/3/6?curriculum_id=506324b3a7dffd00020bf661


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


#2

Try myEmperor instead of myPenguin in this situation.


#3

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


#4

I figured it out thank you


#5

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


#6

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