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

Ivan Sidorov
Ivan Sidorov
3,075 Points

I don't understand how to solve this challenge.

I don't understand how to solve this challenge.

The question is "Inside the play method, write an empty if statement that checks if it's the players turn. Use dot notation."

for this part of code

object.js
const player1 = {
    name: 'Ashley',
    color: 'purple',
    isTurn: true,
    play: function(){
        // write code here.
    }
}

I am writing

if ( this.isTurn ) {}

but it's incorrect

2 Answers

Ivan Sidorov
Ivan Sidorov
3,075 Points

Bad test at teamtreehouse :(

if ( this.isTurn )  {}  // not working
if (this.isTurn)  {}  // working

spaces iside if statement is incorrect

Hi Ivan

You are correct with your answer, however, Treehouse seems to be returning incorrect because of the spaces around your answer within the if statement.

So yes you are correct, just remove the extra spaces like below:

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

      }
    }
}