Workshop › Whack-a-Mole › Step 11 of 18
The seconds left are shown on the right, and when the time is up the round is over and the moles hide.
```js
if (now >= endsAt) {
state = 'over'
for (const hole of holes) hole.upUntil = 0
return
}
if (state === 'playing') {
ctx.textAlign = 'right'
ctx.fillText('Time: ' + Math.ceil((endsAt - now) / 1000), canvas.width - 12, 28)
}
```now reaches endsAt, the state becomes 'over' and every hole is emptied.(endsAt - now) / 1000 is the seconds left; Math.ceil rounds up, so 0.3 seconds still shows as 1.textAlign = 'right' lines the time up against the right edge.update, under the first line, write the time-up block.draw, under the Score line, write the time block.Skills: Game states, The game loop