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 trialMuhammad Raza
3,678 Pointscan somebody please look at my code and tell me what i am missing thanks
const player1 = { name: 'Ashley', color: 'purple', isTurn: true, play: function() { if ( player1.isTurn === true ) { } } }
const player1 = {
name: 'Ashley',
color: 'purple',
isTurn: true,
play: function() {
if ( player1.isTurn === true ) {
}
}
}
1 Answer
Steven Parker
231,184 PointsThe "Bummer" message had a few hints, including "Are you using the this keyword?", which is the issue here.
An object should never reference itself by name, us the special keyword "this" instead:
if ( this.isTurn ) {
You can also test Booleans by just naming them, you never need to compare them with "true".