Skip to content

Commit

Permalink
leaderboard now displays with score next to it
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Fierro committed May 1, 2024
1 parent f5846e9 commit 60a2f7f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ <h3>Current Words</h3>
case "startGame":
setupGameScreen(msg.grid, msg.players);
updateWordList(msg.words);
updateLeaderboard(msg.players);
break;
case "updateScores":
updateLeaderboard(msg.scores);
Expand Down Expand Up @@ -276,11 +277,12 @@ <h3>Current Words</h3>

function updateLeaderboard(players) {
var leaderboardDiv = document.getElementById('leaderboard');
leaderboardDiv.innerHTML = '';
players.forEach(function (player) {
var entry = document.createElement('div');
entry.textContent = player.nickname + ': ' + player.score;
leaderboardDiv.appendChild(entry);
leaderboardDiv.innerHTML = '<h3>Leaderboard</h3>'; // Clear current content but keep the header

players.forEach(function(player) {
var playerEntry = document.createElement('div');
playerEntry.textContent = `${player.nickname}: ${player.score}`;
leaderboardDiv.appendChild(playerEntry);
});
}

Expand Down

0 comments on commit 60a2f7f

Please sign in to comment.