18/30


#1

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, numLegs){
this.name = name;
this.numLegs = numLegs;
}
// create a sayName method for Penguins here

Penguin.prototype.sayName = function(){
console.log("Hi my name is " + this.name)

}

// our test code
var theCaptain = new Penguin("Captain Cook", 2);
theCaptain.sayName();


#4

Okay, your first problem is that Codecademy wants you to realize that penguins always have 2 legs. So you should not have to take that as a parameter in your function. Your code:

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

should be:

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

Also, right after that block of code you need to insert this line:

Penguin.prototype = new Animal();

to make the Penguins be 'classified' as an Animal and inherit all of the properties of an Animal


#5

I hope that was understandable!