Its all in the genes


#1

my code give me this error:
ReferenceError: numLegs is not defined

// create your Animal class here
function Animal(name,numLegs){
this.name = name;
this.numLegs = numLegs;
}
// create the sayName method for Animal
Animal.prototype.sayName = function(){
console.log(name);
console.log(numLegs);
};
// provided code to test above constructor and method
var penguin = new Animal("Captain Cook", 2);
penguin.sayName();


#2

Animal.prototype.sayName = function(){
console.log(this.name);
console.log(this.numLegs);
};

:slight_smile:


#3

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