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

How 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
Mike Hatch
14,940 Points

You 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!

Hey 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
Mike Hatch
14,940 Points

Hey 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."

That Worked!! You are the man Mike. I appreciate your help.