Skip to content

Commit

Permalink
local storage fix null
Browse files Browse the repository at this point in the history
  • Loading branch information
MaryamAbdul-Aziz committed Jan 8, 2024
1 parent 910045e commit e9fa525
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions _posts/2023-12-05-CSSE-oop-game-levels.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ document.getElementById('leaderboardButton').addEventListener('click', showLeade
const playerScore = document.getElementById("timeScore").innerHTML;
const playerName = prompt(`You scored ${playerScore}! What is your name?`);
let temp = localStorage.getItem("playerScores");

if (!temp) {
temp = "";
}
s
temp += playerName + "," + playerScore.toString() + ";";
localStorage.setItem("playerScores", temp);

Expand Down

0 comments on commit e9fa525

Please sign in to comment.