16. All in the genes


#1


I'm not sure what's going wrong. I'm getting "Oops, try again. It looks like your Animal.prototype.sayName method does not properly log to the console 'Hi my name is [name]' where [name] is the name of the Animal" as an error message.


// 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();


#2

strings printed generally have to be an exact match, you have:

Hi, my

it should be:

Hi my

without the comma


#3

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