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 trialBeth Larcombe
5,403 PointsString 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
Bramyn Payne
19,589 PointsHey 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.
Beth Larcombe
5,403 PointsBeth Larcombe
5,403 PointsThanks Bramyn!