Skip to content

Instantly share code, notes, and snippets.

@Srushtika
Created June 11, 2020 12:43
Show Gist options
  • Save Srushtika/a7e7d71b345586d7b85de6435344654e to your computer and use it in GitHub Desktop.
Save Srushtika/a7e7d71b345586d7b85de6435344654e to your computer and use it in GitHub Desktop.
Code snippet 36 - For multiplayer space invaders article
let winner = localStorage.getItem("winner");
let firstRunnerUp = localStorage.getItem("firstRunnerUp");
let secondRunnerUp = localStorage.getItem("secondRunnerUp");
let totalPlayers = localStorage.getItem("totalPlayers");
document.getElementById("winner-announcement").innerHTML =
winner + " won the game!";
if (firstRunnerUp) {
document.getElementById("first-runnerup").innerHTML =
firstRunnerUp + " got the highest score";
}
if (secondRunnerUp) {
document.getElementById("second-runnerup").innerHTML =
secondRunnerUp + " got the next highest score";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment