Workshop › Simon Says Colors › Step 25 of 27
The score is the longest sequence you repeated: failing in round 5 means you did round 4, so it is
sequence.length - 1. The best score is kept in localStorage, which survives page reloads.
```js
let best = Number(localStorage.getItem('simon-best')) || 0
state = 'over'
const score = sequence.length - 1
if (score > best) {
best = score
localStorage.setItem('simon-best', best)
}
return
```localStorage.getItem('simon-best') reads the saved text, or null; Number(...) makes it a number and || 0 uses 0
when there is nothing.sequence.length - 1; a higher score becomes the best and is saved with setItem.let litFor, write the best line.press, inside the wrong-pad block, between state = 'over' and return, write the score lines.Skills: Game states
← Faster and faster Show the best score →