There are two main goals I want to achieve with this section:
- I aim to show the updated high score each time the page is refreshed.
- Currently, the high score resets to 0 whenever the page is reloaded because of
. I am uncertain about how to set it properly without resetting it back to 0 every single time the page reloads.localStorage.setItem('high_score', 0);
let score = 0;
var high_score = 0;
localStorage.setItem('high_score', 0);
document.getElementById('high_score').innerHTML="HIGH<br>SCORE:<br>" +
localStorage['high_score'];
if (score > parseInt(localStorage.getItem('high_score'), 10)) {
localStorage.setItem('high_score', score);
}