Workshop › Bomberman-style Arena › Step 41 of 42
Your fastest win is kept in localStorage, the browser's little notebook that survives closing the page. Fewer
seconds is better; 0 means "no win yet".
```js
let best = Number(localStorage.getItem('bomber-best')) || 0
state = 'won'
const seconds = Math.floor(frames / 60)
if (best === 0 || seconds < best) {
best = seconds
localStorage.setItem('bomber-best', best)
}
ctx.fillText('Time ' + Math.floor(frames / 60) + (best ? ' Best ' + best : ''), canvas.width - 8, 22)
```localStorage.getItem reads the saved text (or null); Number(...) makes it a number and || 0 falls back to 0.setItem if there is no best yet or it is faster.(best ? ' Best ' + best : '') adds the best only when there is one.let frames write the best line.update, inside the win block under state = 'won', write the saving lines.draw, extend the Time text with the best.Skills: Game states
← A clock Build it yourself: a smarter enemy →