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 Filling Out the Play Method

Not sure what I'm missing here

I'm supposed to write an empty if statement inside play to check if it's the player's turn, and I'm obviously missing something... but can't seem to figure it out.

const player1 = {
    name: 'Ashley',
    color: 'purple',
    isTurn: true,
    play: function(){
     if (this.isTurn==true){

2 Answers

Alexander Lee
Alexander Lee
5,964 Points

While your solution is not incorrect,

if (this.isTurn) {}

should suffice and also seems to be the answer they're looking for here.

Thanks Alexander. I’m a little confused at why that works. Is it because that key has a Boolean value and it’s understood upon calling it?

Alexander Lee
Alexander Lee
5,964 Points

Yes, in Javascript and many other programming languages you can safely omit the ==true part altogether dealing with Booleans as it is implied.