16.It's all in the genes


Here is my code:
// 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 " + penguin["name"]);
// provided code to test above constructor and method
var penguin = new Animal("Captain Cook", 2);

It prints out what it's suppose to but it's not letting me pass. Any thoughts?


Your sayName method is logging the property name of the penguin object, when it should work with the object which called the sayName method.

You need to refer to the object that called the method, not the object you created.

Hint: What does the this keyword do?


so if I do this.Animal[penguin] it passes me but doesn't output what it suppose to. is that on the right track?


figured it out! Thanks for your help!