Workshop › 2048 › Step 23 of 26
The best score is kept in localStorage, which the browser keeps after the page is closed, and shown at the top
right.
```js
let best = Number(localStorage.getItem('2048-best')) || 0
addTile()
if (score > best) {
best = score
localStorage.setItem('2048-best', best)
}
ctx.textAlign = 'right'
ctx.fillText('Best: ' + best, canvas.width - GAP, TOP / 2)
```getItem reads the saved text or null; Number(...) || 0 makes it a number, 0 the first time.best and is saved with setItem.textAlign = 'right' puts the text's right end GAP pixels from the right edge.let keepPlaying write let best.move, under addTile(), write the if (score > best) block.draw, under the Score line, write the two Best lines.Skills: Game states