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

:) :((
:) :((
6,776 Points

Please help i dont see the error on the challange :(

I know its something stupid but i dont see it please help

object.js
const player1 = {
name:"Mark",
color:"Red",
isTurn: true ,
play() : function() 
}

1 Answer

Ignacio Rocha
Ignacio Rocha
7,462 Points

First of all is not stupid, everyone sometime has little mistakes is all part of the learning process.

your code is almost perfect, your mistake is in the play function: when you declare a function inside an object literal you have to declare the function with parentheses and curly brackets like so:

const player1 = {
  name:"Mark",
  color:"Red",
  isTurn: true ,
  play: function() { }
}
Steven Parker
Steven Parker
231,236 Points

You could also use the more compact "arrow" syntax:

  play: () => {}