Workshop › 15 Puzzle › Step 23 of 27
A state says whether we are 'playing' or the puzzle is 'solved'. After every move we check; once solved, no more
moves are taken.
```js
let state // 'playing' or 'solved'
state = 'playing'
function move(i) {
if (state !== 'playing' || slide) return
// ...
moves += 1
if (isSolved()) {
state = 'solved'
}
}
```'playing'.move now returns when the game is not being played or a tile is sliding.state becomes 'solved'.let moves write let state ....reset, under moves = 0, write state = 'playing'.move, change the first line, and at the end write the if (isSolved()) block. Press Run.Skills: Game states
← Smooth sliding Show the win →