Loading video player…

References: Two Names, One Object (Overview)

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:

Language: Text
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.

Download

Course Slides (.pdf)

640.8 KB
Download

Sample Code (.zip)

19.6 KB

00:00 Welcome to References: Two Names, One Object. This course is about changing data without changing it somewhere else by accident. In bigger programs, that’s hard to spot, because nothing crashes.

00:14 The Okafor family plans their meals a week at a time. Here’s a first taste of the planner you’ll build for them. It prints last week, then next week.

00:25 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. Last week has to stay exactly as it was.

00:42 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.

00:55 You’ll edit arrays with .slice() and .splice(), and predict when two names share one array or object. You’ll compare records by identity and by contents, and unpack them with destructuring.

01:08 You’ll merge records with spread, and write updates that leave the original untouched. And you’ll build the Okafor family’s meal planner, and explain which parts of next week are new and which are shared.

01:22 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().

01:31 You need a current Node LTS, a terminal, and any editor.

01:37 It’s the second course on the Intermediate JavaScript path, and it stands on its own.

01:44 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.

02:00 A quiz closes the course. Next, in Edit Arrays With slice() and splice(), you’ll edit the family’s lists of dinners and groceries.

Become a Member to join the conversation.