You’ve now built every piece a game night planner needs. You can describe a game as a record, keep a shelf of records in an array, pick out the games that fit, and find one game by its id and change it. In this project, you’ll put those pieces together into a small shelf helper, a set of functions that answers the questions a group asks before it opens a box.
This page is the brief. It describes the shelf, states exactly what each function must do, and splits the work into the steps that the next two exercises check. Read it once now, and keep it open while you work, because the exercises refer back to these rules.
This is the course’s mini-project, and you’ll build it on-site with tests that give you feedback after every run. Later in the course, your final project is a separate program of your own that you’ll write and run locally.
Meet the Shelf
Your helper works with a bigger shelf than the one in the video on ids, with six games and its own sticker numbers. Each record has the same four fields. The id is the sticker number on the box, title is the game’s name, maxPlayers is the maximum number of people who can play it, and minutes is how long a round usually takes. Copy the shelf into scratch/shelf.js and inspect it:
scratch/shelf.js
const shelf = [
{ id: 12, title: "Dixit", maxPlayers: 6, minutes: 30 },
{ id: 3, title: "Codenames", maxPlayers: 8, minutes: 15 },
{ id: 7, title: "Catan", maxPlayers: 4, minutes: 90 },
{ id: 2, title: "Azul", maxPlayers: 4, minutes: 45 },
{ id: 9, title: "Codenames", maxPlayers: 8, minutes: 15 },
{ id: 5, title: "Splendor", maxPlayers: 4, minutes: 30 },
];
console.table(shelf);
Run scratch/shelf.js to see the shelf in a table:
$ node scratch/shelf.js
┌─────────┬────┬─────────────┬────────────┬─────────┐
│ (index) │ id │ title │ maxPlayers │ minutes │
├─────────┼────┼─────────────┼────────────┼─────────┤
│ 0 │ 12 │ 'Dixit' │ 6 │ 30 │
│ 1 │ 3 │ 'Codenames' │ 8 │ 15 │
│ 2 │ 7 │ 'Catan' │ 4 │ 90 │
│ 3 │ 2 │ 'Azul' │ 4 │ 45 │
│ 4 │ 9 │ 'Codenames' │ 8 │ 15 │
│ 5 │ 5 │ 'Splendor' │ 4 │ 30 │
└─────────┴────┴─────────────┴────────────┴─────────┘