Welcome to References: Two Names, One Object! This course is about changing data without changing it somewhere else by accident. In bigger programs, that kind of change is hard to spot, because nothing crashes.
In this course, you’ll build a meal planner for the Okafor family, who plan their meals a week at a time. Next week is last week with three changes: two dinners swap, Friday’s takeout pizza goes, and egusi soup comes in. A helper lists the days that changed. Run with node planner.js, the finished planner prints both weeks:
Last week
Monday (Ngozi): leftover rice, then jollof rice
Tuesday (Chidi): egg sandwiches, then pepper soup
Wednesday (Ada): pepper soup, then spaghetti and meatballs
Thursday (Emeka): salad wraps, then bean tacos
Friday (Chidi): bean tacos, then takeout pizza
Saturday (Ada): pancakes, then veggie stir-fry
Sunday (Grandma Ifeoma): moi moi, then chicken curry
Next week
Monday (Ngozi): leftover rice, then jollof rice
Tuesday (Chidi): egg sandwiches, then bean tacos
Wednesday (Ada): pepper soup, then spaghetti and meatballs
Thursday (Emeka): salad wraps, then pepper soup
Friday (Chidi): bean tacos, then egusi soup
Saturday (Ada): pancakes, then veggie stir-fry
Sunday (Grandma Ifeoma): moi moi, then chicken curry
Changed: [ 'Tuesday', 'Thursday', 'Friday' ]
Last week has to stay exactly as it was. A quick copy of last week looks like the right start, but it can quietly change last week too. Why would a change to next week reach last week? This course answers that question.
What You’ll Learn
By the end of this course, you’ll be able to:
- Edit arrays with
.slice()and.splice(), and predict when two names share one array or object - Compare records by identity and by contents, and unpack them with destructuring
- Merge records with spread, and write updates that leave the original untouched
- Build the Okafor family’s meal planner, and explain which parts of next week are new and which are shared
Before You Start
You should know functions, loops, arrays, and objects in Node, and how to hand arrow functions to array methods like .map() and .filter(). You’ll need a current Node LTS, a terminal, and any editor.
This is the second course on the Intermediate JavaScript path, and it stands on its own.
How the Course Works
You’ll read text lessons, watch short videos, and run every example in your terminal. Each section ends with a browser exercise, checked by tests. In the project, you’ll build the planner, then talk your code through with the RealJS mentor. A quiz closes the course.
Next, in Edit Arrays With slice() and splice(), you’ll edit the family’s lists of dinners and groceries.