A
A
Alexander Ivanov2018-01-28 09:55:33
JavaScript
Alexander Ivanov, 2018-01-28 09:55:33

How to write a comparison operator correctly?

// so the state changes, but it is necessary that it does not change, but I'm stupid

constructor(props) {
        super();
        this.state = {
            gameBoard: arr,
            turn: 'X',
            player: 0,
            connect: 'disabled',

        }
    }
    updateBoard(loc) {
if(this.state.player = 1){ // так state меняется а нужно чтобы не менялось но я туплю
                this.setState({ turn: '0' });
            } else if (this.state.player = 2){
                this.setState({ turn: 'X' });
            }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2018-01-28
@cimonlebedev

if (this.state.player === 1) ...
Comparison Operators and Boolean Values

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question