From 60a2f7fce0fcb33c18c57df3d4a50377e61c2a79 Mon Sep 17 00:00:00 2001 From: Anthony Fierro Date: Tue, 30 Apr 2024 20:53:12 -0500 Subject: [PATCH] leaderboard now displays with score next to it --- html/index.html | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/html/index.html b/html/index.html index 7a502b6..bfd54f4 100644 --- a/html/index.html +++ b/html/index.html @@ -151,6 +151,7 @@

Current Words

case "startGame": setupGameScreen(msg.grid, msg.players); updateWordList(msg.words); + updateLeaderboard(msg.players); break; case "updateScores": updateLeaderboard(msg.scores); @@ -276,11 +277,12 @@

Current Words

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 = '

Leaderboard

'; // 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); }); }