Any idea


#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
varPenguin = function (name , numLegs){
    this.name=name;
    this.numLegs = numLegs;
}

// create a sayName method for Penguins here
Penguin.prototype.sayName = function() { 
    console.log ( "hy my name is " + this.name);
}

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

error:TypeError: Cannot set property 'sayName' of undefined


#2

varPenguin = function (name , numLegs){

you need a space between var and Penguin.


#3

thank you man , i read the codes 100 times and never see it :joy: