Workshop › Tetris-style Blocks › Step 19 of 32
To play again later we must be able to set everything back to the start. newGame() empties the board and brings the
first piece; the variables are declared at the top without values.
```js
let board
let piece
let lastDrop = 0
function emptyRow() {
return Array(COLS).fill(0)
}
function newGame() {
board = Array.from({ length: ROWS }, emptyRow)
spawn()
}
newGame()
requestAnimationFrame(loop)
```let board and let piece move above emptyRow, without values.newGame() gives board a fresh, empty well and spawns the first piece. It replaces the spawn() call at the bottom.let lines above function emptyRow(), and make let board empty.emptyRow write newGame.spawn() with newGame().Skills: Game states, Functions
← Land and lock When the pile reaches the top →