"It's all in the genes" Proper output but still throwing error?


#1


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


My code produces the proper output ("Hi, my name is Captain Cook"), but I'm still getting an error message, and I'm not being permitted to advance.

The error is as follows:
"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"

I've opened the hint to make sure my code follows what they're looking for, and I'm not really sure how my code deviates from the solution, especially since it produces the desired output.


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

I've just realized that the problem is that I am logging "Hi, my name is Captain Cook" instead of "Hi my name is Captain Cook"

Disregard.


#2

It does not produce same result.

It asked to print..

Hi my name is Captain Cook

Not...

Hi , my name is Captain Cook


#3

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