Workshop › Chess › Step 39 of 48
Once the game is over, no more moves: clickSquare stops at once. Instead, a click anywhere on the canvas starts a
new game with reset().
```js
function clickSquare(r, c) {
if (state !== 'playing') return
canvas.addEventListener('pointerdown', (event) => {
if (state !== 'playing') {
reset()
return
}
```return ends the function without doing anything else.clickSquare write the return line.pointerdown listener write the reset() block.Skills: Keyboard and mouse input, Game states
← Check! and the result Show the last move →