"It´s All in the Genes" Code seens right, but don´t pass


#1


https://www.codecademy.com/pt/courses/objects-ii/3/1?curriculum_id=506324b3a7dffd00020bf661#


The code works, but it don´t pass. There this error:
"It looks like your Animal constructor does not take in two arguments and save them as 'this.name' and 'this.numLegs' respectively."
But I did put two arguments

// 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

Sorry guys, already got the problem


#3

I have this same issue.

Code looks correct, what was the fix?


#4

Ignore that. I figured it out.

I was adding a full stop (period) to the console.log ..

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

Once I removed it, it passed ..

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

#5

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