Explain Your Recipe Box

Sam’s recipe box is finished. It saves { version: 2, recipes } under "recipe-box" after every add and delete, loads all four prepared saves, upgrades the old copy from Sam’s kitchen laptop, and asks before Clear my data removes anything. The tests checked what the box does. They couldn’t check whether you can say why it’s built that way. Knowing why is what lets you change it safely when Sam wants something new.

In this session, the AI mentor looks over your box with you and asks one question at a time, in this order:

  1. The shape: You explain why the save is an object with a version number, why the recipes are an array while each ingredient is an object, and why the counts per category aren’t saved.
  2. The load: You walk through loadRecipes() and predict what Sam sees in situations the tests didn’t cover, such as an Incognito window or cleared site data.
  3. A change you haven’t seen: Sam asks for something new, and you change the saved shape without breaking the saves Sam already has, then reload the box with prepared saves to prove it.

Keep your finished code from Exercise: Migrate Old Saves and Clear Data open in another tab, because the mentor will ask you to paste parts of it. Serve it too, at http://127.0.0.1:3000/recipes/index.html with Sam’s page from Project: Sam’s Recipe Box Remembers, since Part 3 has you reload it with prepared saves.

Answer in your own words before asking for help. If arrays of records feel rusty, Records With Objects is a quick refresher. The mentor won’t hand you answers or write the code for you, but it’ll give a hint when you’re stuck. Plan on about fifteen minutes. The session ends with a short debrief on what you explained well and which lesson to revisit for anything that was shaky.

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.