Workshop › Space Invaders-style › Step 16 of 21
The best score is kept in localStorage, so it survives closing the page, and is shown on the GAME OVER band. The band
already promises that Space plays again; the next steps make that true.
```js
let best = Number(localStorage.getItem('invaders-best')) || 0
if (score > best) {
best = score
localStorage.setItem('invaders-best', best)
}
ctx.font = '16px monospace'
ctx.fillText('BEST ' + best + ' SPACE TO PLAY AGAIN', canvas.width / 2, 290)
```localStorage keeps text; Number(...) turns it back into a number, and || 0 covers the first game.now, write best.endGame, save a new record.Skills: Game states
← Game over A wave in a function →