18/30


#1

// the original Animal class and sayName method
function Animal(name, numLegs) {
this.name = name;
this.numLegs = numLegs;
}
Animal.prototype.sayName = function() {
console.log("Hi my name is " + this.name);
};

// define a Penguin class
function Penguin(name, numLegs) {
this.name = name;
this.numLegs = 2;
}

Idk what to do


#2

Close. I know the instructions for this lesson were confusing. I had to go back and redo it just to understand what the poop the lesson was asking for.

TWO THINGS!

function Penguin(name, numLegs) {

1) The lesson states "...because all penguins have 2 legs. Your constructor should only take a name parameter..."
So take out ", numLegs" from your parameters for Penguin.

2) After your closing bracket " } " the instructions state two things

"Penguin.prototype = new Animal();

This means that Penguin inherits properties and methods from Animal"


If that was too obscure I can help some more but it looks like you are on the right track!


#3

@lolman You're right. But you still have to include this.numLegs with a value of 2 inside the class function.


#4

Correct, and you can still do so because you're using the "Penguin.prototype = new Animal()" method. (this.numLegs won't error out because of the prototype used in the next line.)


#5

can some help please am getting opps
function Penguin(name){
this.name = name;
this.numLegs = 2;
}
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)

}