Workshop › Simon Says Colors › Step 12 of 27
Every frame, update counts litFor down by one. When it reaches zero, the light goes out: lit becomes -1. The
loop now updates, then draws.
```js
function update() {
if (litFor > 0) {
litFor -= 1
if (litFor === 0) lit = -1
}
}
function loop() {
update()
draw()
```litFor is above 0, subtract 1 each frame. -= means "take away".loop calls update() before draw(), so each frame first changes the state, then shows it.function draw, write update and an empty line.loop, write update() above draw().Skills: The game loop, Game states
← Light a pad for a while The computer shows a pad →