Workshop › Frogger-style Crossing › Step 21 of 22

Best score

What we are doing

The best score is saved in localStorage when a game ends and shown next to the score.

```js
let best = Number(localStorage.getItem('frogger-best')) || 0

  if (score > best) {
    best = score
    localStorage.setItem('frogger-best', best)
  }

  ctx.fillText('Score: ' + score + '  Best: ' + best, 10, 27)
```

What it means

Your turn

  1. Under let furthest, write best.
  2. In die, save the record after state = 'over'.
  3. In draw, add the best score to the score text.

Skills: Game states

All steps

  1. Road and river
  2. The frog
  3. Keep drawing
  4. Hop
  5. Swipe to hop
  6. Lanes of traffic
  7. Cars
  8. Traffic moves
  9. Hit by a car
  10. Three lives
  11. Play again
  12. Tap to play again
  13. Logs on the river
  14. Stay on the logs
  15. Ride the log
  16. Back in line
  17. Home slots
  18. Get home
  19. Points for progress
  20. Next level
  21. Best score
  22. Build it yourself: a time limit