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

String returned from the play method is wrong?

I feel like what I've got here should be correct, but it's telling me that the string returned isn't what it's asking for?

const player1 = {
    name: 'Ashley',
    color: 'purple',
    isTurn: true,
    play: function(){
        if (this.isTurn) {
          return "player1['name']" + " is now playing!";

1 Answer

Hey Beth!

I think the problem is that you have quotes around player1['name']

If you remove those you should be good. Right now it is interpreting everything inside as a string instead of finding the value that you are looking for.

Thanks Bramyn!