Workshop › Whack-a-Mole › Step 13 of 18
The best score is kept in the browser's localStorage, so it survives a reload, and shown before and after a round.
```js
let best = Number(localStorage.getItem('mole-best')) || 0
if (score > best) {
best = score
localStorage.setItem('mole-best', best)
}
ctx.font = '16px sans-serif'
ctx.fillText('Best: ' + best, canvas.width / 2, canvas.height / 2 + 28)
ctx.fillText('Best: ' + best, canvas.width / 2, 252)
```getItem reads the saved text (null the first time), Number(...) turns it into a number and || 0 falls back to 0.best is updated and saved with setItem.let endsAt, write the best line.update, save the record in the time-up block, before return.draw, add a Best line to the ready block and to the over block.Skills: Game states
← Time's up How far into the round? →