Workshop › Tic-tac-toe › Step 13 of 33
Right now play can overwrite a mark. It must refuse a cell that is not empty, and answer whether the move happened:
true or false.
```js
function play(index) {
if (board[index] !== '') return false
board[index] = player
player = player === 'X' ? 'O' : 'X'
return true
}
```!== means "is not equal to". If the cell is not empty, return false answers "no move" and stops.return true answers "moved".play, above board[index] = player, add the if line.player, add return true.Skills: Game states
← Make a move Listen for clicks →