Workshop › Simon Says Colors › Step 8 of 27
For pads to light up and go dark, the board must be redrawn all the time. A loop draws and asks the browser to run it
again before the next screen refresh (requestAnimationFrame, about 60 times a second).
```js
function loop() {
draw()
requestAnimationFrame(loop)
}
requestAnimationFrame(loop)
```loop draws once, then requestAnimationFrame(loop) books the next turn, so it keeps going.draw() call.loop has no parentheses there: we hand over the function, the browser calls it later.Replace the draw() call at the bottom with the loop function and requestAnimationFrame(loop).
Skills: The game loop
← Light a pad The sequence to remember →