Workshop › OutRun-style Racer › Step 32 of 44
The cars drive too: every frame each moves forward by its own speed, wrapping around the track like we do.
```js
for (const car of cars) {
car.z = (car.z + car.speed) % trackLength
}
```for (const car of cars) runs once for each car.(car.z + car.speed) % trackLength moves it on and wraps it around the end of the track.In update, above position += speed, write the loop followed by an empty line.
Skills: The game loop
← Cars that shrink with distance Rear-end crash →