In the last exercise, you wrote update functions that return a changed copy of a week, a day, or a record, and the tests checked that the original stayed as it was. Each of those functions did one job. The Okafor family needs all of them working together, in one script that turns last week’s plan into next week’s.
In this project, you’ll build that script, the meal planner, and a helper that compares two plans. You’ll put together the pieces from the whole course, and you’ll prove with the planner’s own printout that last week ends with its original values.
Read the Brief
Every Sunday evening, Ngozi plans the coming week. Last week went well, so next week should be the same plan with three changes:
- Swap two dinners: Tuesday’s pepper soup moves to Thursday, and Thursday’s bean tacos move to Tuesday.
- Drop the takeout night: Friday’s takeout pizza comes off the plan.
- Add a new recipe: Egusi soup, the newest card in the recipe box, becomes Friday’s dinner.
Last week’s plan has to stay exactly as it was, because the family uses it to see what they ate and to write the grocery list. So the planner never writes into lastWeek, its day records, or their meal lists. It builds next week from new objects where something changes and shares the rest.
The data has the same shape as in every lesson of this course. The name lastWeek points at an array of seven day records, Monday to Sunday, each shaped { day, cook, meals }. Each meals array holds two strings, lunch then dinner. If you’d like a refresher on records, Records With Objects covers them from the start.