20. Penguin Properties and prototypes


#1


what am i doing wrong?


Oops, try again. Make sure to log the number of legs emperor has!


Replace this line with your code. 
function Penguin(name) {
    this.name = name;
    this.numLegs = 2;
}

// create your Emperor class here and make it inherit from Penguin
function Emperor(name) {
    this.name = name;
    Emperor.prototype = new Penguin();
}

// create an "emperor" object and print the number of legs it has
var emperor = new Emperor("ab");
console.log(emperor.numLegs);


#2

this:

Emperor.prototype = new Penguin();

needs to happen outside your Emperor class deceleration.

prototype extends a class, this needs to happen after the class deceleration.


#3

Thanks :slight_smile:


#4

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