Skip to content

Instantly share code, notes, and snippets.

@Srushtika
Created June 11, 2020 12:42
Show Gist options
  • Save Srushtika/03d39d726f7388753c9f93cfbf1488e9 to your computer and use it in GitHub Desktop.
Save Srushtika/03d39d726f7388753c9f93cfbf1488e9 to your computer and use it in GitHub Desktop.
Code snippet 35 - 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 + " is the first runner up";
}
if (secondRunnerUp) {
document.getElementById("second-runnerup").innerHTML =
secondRunnerUp + " is the second runner up";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment