In Exercise: Confirm Clearing the Week, the meal planner learned to ask before it clears anything, say what it did, and put the focus somewhere useful. Sam’s family recipes, though, are still on index cards in a shoebox, and Sam can never find the one for banana bread.
In this project, you’ll build Sam’s recipe box: a form that adds recipes and refuses bad ones, a filter you reach with one key, and a Delete button that asks first. You’ve met every piece on the shopping list. Now you’ll put them together from a brief, testing each step with the keyboard alone.
Read Sam’s Brief
Sam wants one page that holds every family recipe, where anyone can add a recipe, find one by typing part of its name, and delete one without fear of losing the wrong card. Kofi plans meals with the keyboard alone, and Mei listens with a screen reader, so the page has to work for both of them.
Each recipe is a record with six properties:
id, fromcrypto.randomUUID(), so two recipes never share onename, such asBanana bread, without spaces at either endservings, a number from 1 to 20minutes, a number of at least 1, for how long the recipe takescategory, one ofsoup,main,baking, ordessertvegetarian,trueorfalse
Banana bread’s record looks like this, with its ID shortened:
{
id: "8f1c2a4e-...",
name: "Banana bread",
servings: 8,
minutes: 70,
category: "baking",
vegetarian: true,
}
The box starts with five recipes Sam copied from the cards: Grandma Ines’s lentil soup, Sunday roast chicken, Banana bread, Weeknight fried rice, and Lemon drizzle cake.
The list shows one row per recipe, such as Banana bread (serves 8, 70 min), baking, vegetarian, followed by a Delete Banana bread button. A recipe that isn’t vegetarian has no , vegetarian at the end: Weeknight fried rice (serves 2, 20 min), main.
The recipes live in one array, recipes, as Priya’s guests and Sam’s shopping items did. Every change goes to the array first, and then render() redraws the list from it. The page never keeps a second copy of the data, so what Sam sees always matches the array.
Know What Sam Expects
The exercises’ tests check these rules, so read them now and come back to them as you build: