16. What's the matter with my code?


#1

Hi,

I've done what has been asked, used the previous exercises for help and my output on the console is coming out right "Hi my name is Captain Cook".
But for some reason i'm getting the error message: "Oops, try again. It looks like your Animal.prototype.sayName method does not properly log to the console 'Hi my name is [name]' where [name] is the name of the Animal".

Here's my code:


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

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

var penguin = new Animal("Captain Cook", 2);
penguin.sayName();


#2

HI this line

console.log("Hi my name is " + penguin.name);

instead of penguin.name it should be this.name