20. penguins need help


#1

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;
}

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


#2

You will need to be case sensitive with writing your code.

Here,

The three(3) quoted portions of your code should be Emperor and not emperor.

So, you should have:

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

function Emperor(name) {
    this.name = name;
}
Emperor.prototype = new Penguin();

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

#3

Thank you so much I really couldn't see the mistake


#4

You're welcome.

Have fun coding! :slight_smile:


#5

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