Object method is not responding

Tell us what’s happening:
It seems right but doesn’t work!

Your code so far

let dog = {
name: "Spot",
numLegs: 4,
sayLegs: function() {
return "This dog has" + dog.numLegs + "legs.";

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36.

Challenge: Create a Method on an Object

Link to the challenge:

I suggest you tru to put this in a console.log like this:

1 Like

The problem is that you’re trying to use dog.numLegs before dog actually exists (it only exists after the whole let dog = ... line). I think you need to use this.numLegs (where this refers to the object, before it’s assigned to dog).

1 Like

I’ve tried that too my friend.

I found out the problem , you should have gaps on either side of “4” when it’s returned.
However thanks for your reply dude.

Bah! I should have run the code before replying.