16. it's all in the genes


#1

Tired and cannot find my error! Please help.

// 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("Hi my name is" + this.name)
}

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


#3

add the semicolon at the end of the method.

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

#4

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