Workshop › Klondike Solitaire › Step 37 of 40
Your fastest win is kept in localStorage, which the browser keeps even after the page is closed, so there is always a time
to beat. It is shown at the top right.
```js
let best = Number(localStorage.getItem('solitaire-best')) || 0
const seconds = Math.floor(frames / 60)
if (best === 0 || seconds < best) {
best = seconds
localStorage.setItem('solitaire-best', best)
}
ctx.textAlign = 'right'
ctx.fillText('Best ' + (best ? best + 's' : '-'), canvas.width - LEFT, 24)
```localStorage.getItem(name) reads a saved text (or null); Number(...) makes it a number; || 0 uses 0 when there is
none.best ? best + 's' : '-' shows 95s, or - while best is 0.let won write let best = ....checkWin, under won = true, write the five lines.draw, under the Moves text line (above if (won)), write the two lines.Skills: Game states
← A new game Snapshots of the table →