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 trialStephen Powers
12,091 PointsNot 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
5,964 PointsWhile your solution is not incorrect,
if (this.isTurn) {}
should suffice and also seems to be the answer they're looking for here.
Stephen Powers
12,091 PointsThanks 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
5,964 PointsYes, in Javascript and many other programming languages you can safely omit the ==true part altogether dealing with Booleans as it is implied.