Workshop › Chess › Step 38 of 48
The message at the top tells the story: Check! in front when the side to move is in check, and the result when the
game is over.
```js
let message = turn === 'w' ? 'White to move' : 'Black to move'
if (state === 'playing' && inCheck(turn)) message = 'Check! ' + message
if (state === 'checkmate') message = 'Checkmate: ' + (turn === 'w' ? 'black' : 'white') + ' wins! Click to play again'
if (state === 'stalemate') message = 'Stalemate: a draw. Click to play again'
```let because the message may be replaced by the lines below.turn is the side that was mated, so the winner is the other one.In draw, change const message to let message and write the three lines under it.
Skills: Drawing on a canvas, Game states
← Checkmate and stalemate Click to play again →