Workshop › Sokoban › Step 18 of 29
A level is solved when every box sits on a goal. solved() asks exactly that with every, and a solved board
freezes.
```js
function solved() {
return boxes.every((box) => goals.has(key(box.x, box.y)))
}
function move(dx, dy) {
if (solved()) return
```every runs the test for each box and is true only if it is true for all.move returns at once when the level is solved.function move, write solved and leave an empty line.move, write if (solved()) return as the first line. Press Run.Skills: Game states
← A box on a goal turns green On to the next level →