From 3200f0368efa38e0fd323093f57c975bf1a60fc1 Mon Sep 17 00:00:00 2001 From: rarora2025 Date: Wed, 10 Dec 2025 19:05:50 -0500 Subject: [PATCH] =?UTF-8?q?Completed=20coding=20exercise=20=E2=80=93=20Rah?= =?UTF-8?q?ul=20Arora=20(ra3245)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.py | 2 ++ static/scoreboard.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 372a266c..cf40f484 100644 --- a/server.py +++ b/server.py @@ -51,6 +51,8 @@ def increase_score(): if team["id"] == team_id: team["score"] += 1 + scoreboard.sort(key=lambda x: x["score"], reverse=True) + return jsonify(scoreboard=scoreboard) diff --git a/static/scoreboard.js b/static/scoreboard.js index 34ce2009..9d437606 100644 --- a/static/scoreboard.js +++ b/static/scoreboard.js @@ -2,6 +2,7 @@ function display_scoreboard(scoreboard){ $("#teams").empty(); $.each(scoreboard, function(index, team){ addTeamView(team.id, team.name, team.score); + }); } @@ -32,7 +33,7 @@ function increase_score(id){ contentType: "application/json; charset=utf-8", data : JSON.stringify(team_id), success: function(result){ - + display_scoreboard(result.scoreboard); }, error: function(request, status, error){ console.log("Error"); @@ -41,6 +42,7 @@ function increase_score(id){ console.log(error) } }); + } $(document).ready(function(){