JavaScript Object-Oriented JavaScript Object Basics Filling Out the Play Method

AJ Jhaveri
AJ Jhaveri
Full Stack JavaScript Techdegree Student 512 Points

I have no idea why this isn't working

I have no idea why this isn't working

object.js
const player1 = {
    name: 'Ashley',
    color: 'purple',
    isTurn: true,
    play: function(){
        if (this.isTurn() = true){}
    }
}

1 Answer

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 48,710 Points

isTurn is a property so it isn't followed by parentheses. You also need to use a comparison operator instead of an assignment operator when checking for true. As an alternative you could just leave it off:

if (this.isTurn == true){}

or

if (this.isTurn){}