Workshop › OutRun-style Racer › Step 36 of 44
We time each lap by counting frames: lapTime grows by 1 every frame and goes back to 0 when a new lap starts. At 60
frames a second, 60 frames is one second.
```js
let lapTime // frames
lapTime = 0
function update() {
lapTime += 1
lap += 1
lapTime = 0
```lapTime counts frames; reset sets it to 0.update it grows by 1 each frame.lap += 1, it goes back to 0.let lap write let lapTime; in reset, under lap = 1, write lapTime = 0.update write lapTime += 1.lap += 1, write lapTime = 0.Skills: The game loop, Game states
← Show the lap Show the time →