Im learning inheritance. In the code below
1)penguin inherits from Animal
2)when I call penguin.sayName(); why does it output "Hi my name is undefined";
function Animal(name,numLegs){
this.name = name;
this.numLegs = numLegs;
}
Animal.prototype.sayName = function(){
console.log("Hi my name is " + this.name);
};
function Penguin(){}
Penguin.prototype = new Animal();
var penguin = new Penguin("Captain Cook", 2);
penguin.sayName();