Workshop › OutRun-style Racer › Step 41 of 44
A race has an end. When the last lap is crossed, the race is 'finished'; otherwise the next lap starts as before.
```js
if (lap === LAPS) state = 'finished'
else {
lap += 1
lapTime = 0
}
```state becomes 'finished' and update stops the car from the next frame on.else) the next lap starts. The two old lines move inside the else block.In the lap block, replace lap += 1 and lapTime = 0 with the if ... else shown.
Skills: Game states
← Racing or finished Finished! →