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

Hanna Zeif
Hanna Zeif
11,309 Points

Can't figure out what this challenge wants

Why is this not working? The error message I get tells me to check that I'm using "this", dot notation, and inside the method. All are true, and I've tried a variety of things already. What is wrong here?

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

      if (this.isTurn === true){
      }
    }
}

1 Answer

Hi Hanna Zeif ,

I believe the question is asking you to exclusively use dot notation inside the method, however your code is also correct.

const player1 = {
    name: 'Ashley',
    color: 'purple',
    isTurn: true,
    play: function(){
      // use dot notation only. No need to include === true for boolean values.
      if (this.isTurn){
      }
    }
}