It's In The Genes - Can't console the correct thing


I can't console the correct thing.

Please help me find the error in this code.

// create your Animal class here

function Animal(name,numLegs) { = name;
    this.numLegs = numLegs;

// create the sayName method for Animal

Animal.prototype.sayName = function() {
    console.log("Hi my name is [name]");

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


you made name accessible inside the object thanks to this line: = name;

so you need to use, also you need to join the string and variable together:

var example = "how to join the strings";
console.log("this is " + example);

you need to the same way to join your string and the variable (


Hi, thanks for the correction, but I didn't get what you said in the first paragraph. Is it wrong to use = name ?


no, it is good you do this: = name

it means you can access the name through the this object, it was just just information that you needed to in your sayName method.


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