16. It's All in the Genes


The error message:
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

Cannot understand what's wrong:((

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


The string that the error message mentions is slightly different from what you've got. You'll need to compare them in some way that you'll detect any differences, however small


Checked different variants, but still can't fix the error:(


There's only one variant to try, did you try that one? If you're wildly guessing without looking up what it should be, then you're likely to guess only wrong ones.
Compare what you print out to what it's asking for.

Copy them and put one under the other, each character should match. In the code you posted above, they don't.

Even manual comparison is fairly easy:


You just need to make sure that the comparison isn't just casually eyeballing it, that you will find differences if there are any

You have two versions. There are something like 20 characters to compare.


Erase the coma in "Hi, my name is "

I had the same problem :slight_smile:


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