Explain Your Meal Planner

Your meal planner now does everything the Okafor family asked for. It builds next week from last week, swaps two dinners, removes the takeout pizza, adds egusi soup, and prints both weeks. diffPlans() names the days that really changed. The tests have checked what your functions return, but they can’t tell whether you can explain why last week stayed as it was.

In this review, you’ll explain your planner to your mentor, out loud in your own words, and then make an unfamiliar change to the plan. You’ll predict which names reach the same object, and you’ll write an update that leaves the original alone.

Get Your Planner Ready

The conversation works from your code, so have it in front of you before you begin. The two project exercises ran in the browser, so first put their pieces together in one file of your own:

  1. Create planner.js and paste in the lastWeek array from the final code of Trace Two Names to One Object.
  2. Below it, paste your four functions from Exercise: Plan Next Week, then diffPlans() and its helper from Exercise: Compare Two Plans. Delete the export in front of each function.
  3. At the end, add the five closing lines from the project brief, then console.log("Changed:", diffPlans(lastWeek, nextWeek));.
  4. Run node planner.js and check that it prints both weeks as in the brief’s printout, followed by the changed days.

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.