I am trying to make a minesweeper game with a leaderboard and update it to HTML
It’s a really long code so I uploaded it to Fiddle
`function updateLeaderboard() {
var savedTimes = localStorage.setItem('bestTimes', JSON.stringify(SCORES))
if (savedTimes) SCORES = JSON.parse(savedTimes)
var strHTML = ``
for (var i = 0; i < SCORES.length; i++) {
strHTML += `<p>${i+1}. ${SCORES[i].name}: ${SCORES[i].time} seconds</p>`
}
ELEMENTS.leaderboard.innerHTML = strHTML
}`
Basically, I want it to save the top 3 scorers to localStorage and display it to leaderboard.inner HTML and keep that constantly updated
I can see that the issue is that I update the leaderboard (updateLeaderboard line 346) with the SCORES content and that this content is reset every refresh..
In english, I believe I just need to put the localstorage information into innerHTML rather than SCORES.name and SCORES.time but I don’t understand how to do that, stringify turns it into a wild string that I might have to put dozens of splits into, and I dont have that much experience with JSON
I would love for some help or assistance (not even the full code, because I need to know how to do this myself,but more like guidance)
Thank you!