It's All in the Genes


#1

Excercise 16

Please help. I keep getting this error message but Ican't see what I;m doing wrong. TypeError: Cannot set property 'sayName' of undefined


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

// create the sayName method for Animal
Animal.protoype.sayName = function () {
    console.log("Hi my name is " + this.name);
};



// provided code to test above constructor and method
var penguin = new Animal("Captain Cook", 2);
penguin.sayName();


#2

Spelling error... prototype


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.