Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Object-Oriented JavaScript Object Basics Creating Object Literals

Adam Kohler
Adam Kohler
1,970 Points

Still not working. What does it mean the object is missing the method?

I'm trying to figure out what my code is missing. Any thoughts?

object.js
const player1 = {
name: "Lola",
color: "Pink",
isTurn: true,
method: function play(){}
};

1 Answer

Steven Parker
Steven Parker
231,268 Points

The instructions ask you to "Add an empty method to the object literal called play()", but this code is adding a method named "method".

Adding an empty method named "play" would look like this:

  play: function () {}    // the function itself doesn't need a name