Project: Priya's RSVP Board

Priya’s guest list now does its job on game night. Each Check in button marks its guest’s row, and the arrivals count keeps up with every click. The games list below it hasn’t changed since Priya first built it, though. It’s still five lines of text that nobody can click.

In this project, you’ll turn those lines into an RSVP board. Guests will mark the games they’re bringing, vote on what to play first, and see the leading game stand out. A Quick games only button will trim the list for a short evening. You’ve met every piece in this course’s lessons, and this time you’ll put them together from a brief, without a script to follow. Start with what Priya has asked for.

Read Priya’s Brief

Priya wants to stop collecting replies in a group chat. Her idea is that guests click on the page to say which games they’ll bring and to vote on what to play first, so she can see the plan at a glance. She still picks the games by editing one array in main.js, and the page follows.

The board replaces the games list with one card per game. A card is still a list item in #games, so the list stays a list and the #games li.long rule still applies to Catan. Each card shows the game’s line from describeGame(), its votes, and two buttons. You can check each part of the finished board by clicking and looking:

  • The cards come in the array’s order, one per game, each with the class card and a data-game-id holding the game’s id, such as catan. Catan, the only game over 60 minutes, keeps the class long.
  • Bringing a game works from a button that names it, such as Bring Catan. A click adds the class bringing to that card, which gives it a pale blue background. A second click takes the class off, for a guest who changes their mind.
  • Votes come from a button such as Vote for Catan on each card. Each click adds one to that game’s count, and the card shows it in a line like Votes for Catan: 2. That’s the line voteLine() built in Exercise: Write the Vote Helpers.
  • The leading game gets the class leading, which draws a border in the accent color. A game leads only while it has strictly more votes than every other game. So no card leads before the first vote, and no card leads during a tie.
  • Quick games only is a button above the cards. Priya counts a game of 45 minutes or less as quick, so the first click hides every card over 45 minutes. The next click shows them again, and so on.

The buttons name their game for the same reason the Check in buttons name their guest. Someone jumping from button to button with Tab hears each one by its own text, and five buttons called Vote wouldn’t tell them which game they’d vote for.

Once all three steps work, a card on the live page looks like this in the Elements panel. The example below shows Catan’s card before anyone clicks a button:

Language: HTML
<li class="card long" data-game-id="catan" data-minutes="90">
  <span>Catan: 3-4 players, 90 minutes</span>
  <span class="votes">Votes for Catan: 0</span>
  <button>Bring Catan</button>
  <button>Vote for Catan</button>
</li>

The data-minutes attribute is there for the Quick games only button, as you’ll see in Step 3. Nothing about the games is typed into index.html. The script builds every card from games, so a sixth game in the array gets a card, buttons, and a count of its own.

In one way, the board is a toy. Everything it knows lives in one browser tab. The votes are in your script, so a reload sets them back to 0, and a guest clicking on another computer starts from 0 too. Keeping them across a reload comes later on the path, and that’s all you need about saving for now.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.