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
Zahra Toto
6,723 PointsTask: Inside the play method, write an empty if statement that checks if it's the players turn. Use dot notation.
const player1 = { name: 'Ashley', color: 'purple', isTurn: true, play: function(){ if (isTurn.this === true) { } } }
2 Answers
Seth Kroger
56,416 PointsYou've got pretty close to the right answer. You just need to switch isTurn and this around so it's this.isTurn (this is the object, and isTurn the property).
Zahra Toto
6,723 PointsAmazing, it worked! Thank you so much. It didn't even cross my mind to leave out the "=== true".
Zahra Toto
6,723 PointsZahra Toto
6,723 PointsThank you very much for your reply! Even when I switch it to this.isTurn, I still keep getting this error message: Bummer: Something is incorrect. Check that you wrote an if statement inside the method. Check that you're using dot notation. Are you using the this keyword?
Seth Kroger
56,416 PointsSeth Kroger
56,416 PointsOK, the challenge seems to be extra picky. Because isTurn is a boolean you can just use
if (this.isTurn) {}. Whileif (this.isTurn === true) is equivalent (though redundant) it only accepts the former.