16. Its All In The Genes


// 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 (a) {
console.log("Hi my name is" + " " + a.name);

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

i submitted this code and it success, but it shows "TypeError: Cannot read property 'name' of undefined" on the console.. can somebody tell me what's going on?


Try changing this part to this.name at the end instead of a.name


yeah i know.. but it seems like my code above still can pass the exercise although it shows error on the console.. which is quite confusing for me


Must be a small bug, try contacting codecademy


console.log("Hi my name is"+" "+[this.name]);

Once try above statement.


Thank you so much for the help with this.