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 trialAdil Ismaaeel
9,438 PointsAdd an empty method to the object literal called play().
Ive tried the different ways to add a function but its not working. Please help
const player1 = {
name: 'adil',
color: 'blue',
isTurn: true
function: play()
}
2 Answers
Patryk Nowak
14,103 PointsHi Adil, you are trying to set property inside an object. 'function' cant be a property name, as this is reserved word in Javascript environment.
Try this instead:
const player1 = {
name: 'adil',
color: 'blue',
isTurn: true,
lestPlay: function() {
play()
}
}
Patryk Nowak
14,103 PointsHi Adil, now I have checked the challenge:
try this:
const player1 = {
name: 'adil',
color: 'blue',
isTurn: true,
play: function() {}
}
Adil Ismaaeel
9,438 PointsAdil Ismaaeel
9,438 PointsI also tried a variation like that after I posted this question but it still doesnt work and I tried yours but nope