Workshop › Endless Runner › Step 14 of 19
The score is the distance divided by 10. When a run ends with a new record, it is saved in the browser's localStorage.
```js
let best = Number(localStorage.getItem('runner-best')) || 0
const score = Math.floor(distance / 10)
if (score > best) {
best = score
localStorage.setItem('runner-best', best)
}
```Math.floor drops the decimals of distance / 10.getItem reads the saved record (null at first, so || 0), setItem saves a new one.let nextIn, write the best line.update, work out the score and save a record.Skills: Game states
← Faster and faster The score counter →