18/30 please help


#1

what am i doing wrong with my code

function Animal(name, numLegs) {
this.name = name;
this.numLegs = numLegs;
}
Animal.prototype.sayName = function() {
console.log("Hi my name is " + this.name);
};

// create a Penguin constructor here
function Penguin(name){
this.name = name;
this.numLegs = 2;
}


#2

when i click save and submit it says

Oops, try again. It looks like the Penguin class didn't inherit from the Animal class!


#3

In order for Penguin to inherit from Animal, we have to add it to Penguin.prototype...

Penguin.prototype = new Animal();

Note that there are no parameters in the above expression.


#4

function Animal(name, numLegs) {
this.name = name;
this.numLegs = numLegs;
}
Animal.prototype.sayName = function() {
console.log("Hi my name is " + this.name);
};

// create a Penguin constructor here
function Penguin(name){
this.name = name;
this.numLegs = 2;
}
Penguin.prototype = new Animal();
penguin.sayName();

its still wrong


#5

just remove the last line of your code i.e
penguin.sayName();

it will be used in the next exercise