Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.