ES6 function in object

Tell us what’s happening:
Describe your issue in detail here.
I tried to use ES6 annotations to create a function in an object and it didn’t work

  **Your code so far**

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

dog.sayLegs();
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36

Challenge: Create a Method on an Object

Link to the challenge:

Hi @Jju17 !

You are getting an error message saying that numLegs is not defined.

They are talking about this part here

That is not the proper way to access a property in objects.

Hint: Dot notation would be handy here :grinning:

1 Like