Priya’s guest list now lives in three files, and her guests have all checked in. Once the game begins, someone has to keep score, and so far that’s been Priya with a pencil and an envelope full of crossed-out totals.
In this project, you’ll build her a scorekeeper: a scoreboard drawn from player records, points scored through one listener, an undo for the last round, and finally the app split into modules. You’ve met every piece in this course. Now you’ll put them together from a brief. Start with what Priya has asked for.
Read Priya’s Brief
Players win and lose points in each round of Priya’s game. She wants a page that shows each player’s total, who’s leading, and the current round, plus a way to undo a round scored by mistake.
The players are the four guests from the RSVP list: Amara, Jonas, Wei, and Sam. The scorekeeper copies each guest into a record with three fields:
id, fromcrypto.randomUUID(), so no two players share one.name, the guest’s name.scores, an array with one number per round. Every player starts with[0], so the board opens on round 1.
After three rounds, Amara’s record could look like this:
{ id: "3b0c9e1e-...", name: "Amara", scores: [2, 0, -1] }
A single total can’t tell you what the last round added, so it can’t undo that round. With one number per round, undo is a pop() on each player’s scores. The last number is the current round’s score, and since every player has the same number of rounds, the first player’s scores.length is the round count.
A line such as Round 3 sits above the New round and Undo last round buttons. Below them, each player gets a row with their name and total, such as Amara: 1, and three buttons that name the player: +1 Amara, -1 Amara, and Remove Amara.
Under the rows, a line names the leader, such as Leader: Amara or Leader: none, and the leader’s row gets the class leading.
The exercises’ tests check these rules: