#Quiz Game doesnt display score from localstorage properly.

1 messages · Page 1 of 1 (latest)

fossil ridge
#

Hey all,
I have been following James's videos how to create a quiz and used it as skeleton for my own as a project.
my problem is localstorage it does save the score but doesnt pull from localstorage after there is no more questions and shows empty same as when u press save it shows null in local storage but mostRecentScore is saved with score. While i run the game again it shows me score from previous game even tho it overwrites the old score to new one but display the old score.
my repo is here:
https://github.com/aboczek/QuizGame

GitHub

This is project portfolio 2 for Code institute course - GitHub - aboczek/QuizGame: This is project portfolio 2 for Code institute course

#

console.log(mostRecentScore) shows me the score

#

I have fixed showing score to work but
const score = {
score: mostRecentScore,
name: userResult.value
};
still shows as null in localStorage when usave it

#

okay i can close this help 🙂 got enligtened and fixed it all
changed
let score = {
score: mostRecentScore,
name: userResult.value
};
to
const score = {
score: window.localStorage.getItem("mostRecentScore"),
name: userResult.value
}

and works 🙂

#

it looks like mostRecentScore wasnt pulled properly from declaring variable
const mostRecentScore = localStorage.getItem("mostRecentScore");

#

found another issue.
highscore works in main menu but wont show new score in there unless i refresh the HTML