17 Help me


#1

I got this error message. "Oops, try again. It looks like you have an error in your code. Here's the message: TypeError: Object doesn't support property or method 'sayName'"

This is 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,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);
};

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

Please help me.


#2

We cannot call a method on the constructor object, only on the instances invoked.

Penguin.sayName();

is what is throwing the error. Remove that line, and take a lesson from this mistake.


#3

Thank you very much.