Workshop › 15 Puzzle › Step 11 of 27
Instead of typing sixteen numbers, solvedTiles() builds the solved board from N. We will need it again to check
whether the puzzle is solved.
```js
const solvedTiles = () => [...Array(N * N - 1).keys()].map((i) => i + 1).concat(0)
function reset() {
tiles = solvedTiles()
}
```Array(15).keys() counts 0 to 14; [... ] puts those numbers in an array..map((i) => i + 1) adds one to each: 1 to 15..concat(0) adds the gap at the end.tiles never changes the "solved" list.colOf, write the solvedTiles line.reset, replace the long list with solvedTiles(). Press Run.Skills: Arrays and objects
← Draw again and again Neighbours →