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

I'm not understanding this question.

it doesn't make any sense to me. when I put return, it says I'm not returning anything. when i put console.log it says error.

object.js
const player1 = {
    name: 'Ashley',
    color: 'purple',
    isTurn: true,
    play: function(){
        if (this.isTurn){
     console.log(`${this['name']} is now playing!`);} 
    }
}

1 Answer

Rohald van Merode
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Rohald van Merode
Treehouse Staff

Hey maliyah patterson 👋

It's hard to tell what went wrong with the return statement as that is not present in the snippet you've shared. I tried to complete the challenge on my end and when returning the string, instead of logging it to the console, your code is passing the tests as expected 🙂

const player1 = {
    name: 'Ashley',
    color: 'purple',
    isTurn: true,
    play: function(){
        // write code here.
      if(this.isTurn){
        return `${this['name']} is now playing!`;
      }
    }
}

Hope this helps!