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 trialBrian Johnson
Front End Web Development Techdegree Graduate 20,818 PointsHow is my string wrong? I need some assistance please
Please help
const player1 = {
name: 'Ashley',
color: 'purple',
isTurn: true,
play: function(){
if (this.isTurn){
return['name'] + 'is now playing!';
}// write code here.
}
}
2 Answers
Mike Hatch
14,940 PointsYou have it mostly right. In Task 2 you omitted using "this". It's the same as you did in Task 1 but instead use brackets which you already did.
This be damned!
Brian Johnson
Front End Web Development Techdegree Graduate 20,818 PointsThat Worked!! You are the man Mike. I appreciate your help.
Brian Johnson
Front End Web Development Techdegree Graduate 20,818 PointsBrian Johnson
Front End Web Development Techdegree Graduate 20,818 PointsHey Mike I tried putting the “this” keyword in front of the “name property like this ex) return this[‘name] ... and that didn’t work. I’m stuck
Mike Hatch
14,940 PointsMike Hatch
14,940 PointsHey Brian.
Leave the code you provided in your original question exactly as it is. You were 90% correct already. Now that you've added "this" before "name", the only mistake you're making is omitting a single quote mark after 'name.' Also, make sure there is a space after "return."