Emperor Penguin (Needs Debug)


#1


function Penguin(name) {
    this.name = name;
    this.numLegs = 2;
}


// create your Emperor class here and make it inherit from Penguin


// create an "emperor" object and print the number of legs it has

Emperor.prototype = new Penguin();

function Emperor (name) {
this.name = name;
}

var emperor = new Emperor("George");
console.log(Emperor.numLegs);


#2

you will first need to create the emperor class before you can make it inherit from penguin.


#3

How would I do that again?


#4

this creates the class:

function Emperor (name) {
this.name = name;
}

this makes it inherit:

Emperor.prototype = new Penguin();

so they need to be in the right order


#5

Which order? I've tried both ways.


#6

please provide exercise url, can't find the exercise


#7

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


#8

this order

then here:

console.log(Emperor.numLegs);

you call methods on the instance (emperor) not the class itself (Emperor)


#9

Thank you so much! I got it now.


#10