Workshop › Memory › Step 10 of 25
Cards will turn over, so the picture must follow every change. A loop redraws the board before every screen refresh
(requestAnimationFrame, about 60 times a second). Then any change to a card shows up by itself.
```js
function loop() {
draw()
requestAnimationFrame(loop)
}
newGame()
requestAnimationFrame(loop)
```loop draws, then books the next turn with requestAnimationFrame(loop).draw() call.loop has no parentheses there: we hand over the function, the browser calls it later.Write loop above newGame() at the bottom, and replace the last draw() with requestAnimationFrame(loop).
Skills: The game loop
← Draw the cards from the list The face of a card →