16 - It's all in genes - "does not properly log to the console"


#1


Hello, I have a funny situation with this exercise. The code I wrote does provide correct output to console (as far as I can tell) but codecademy engine won't accept it - it will throw the code you can see in my post.


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


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


// create your Animal class here
var Animal = function (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

Refresh your browser :slight_smile:


#3

You have a missing semicolon after your console.log command. Fix it like this:

Animal.prototype.sayName = function () {
    console.log("Hi my name is"+ " " + this.name)**;**
};

#4

True. However, it doesn't effect the error in question.
Thank you for pointing that out none the less.


#5

ctrl + f5 , so called "hard" refresh did the trick.


#6

I am also having the exact same problem. Tried both refreshing browser and hard refresh several times. But I am still getting output and the same message appears at the bottom.

"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
æ


#7

simishr can you post your code?


#8

@chris.evo , i solved it later. Turns out, I had a comma after "Hi" in the console log. :slight_smile:
It took me a while to figure it out!
Thank you!