Loading video player…

Modules and JSON: Programs Across Files (Overview)

So far, each program you’ve written fits in one file. Bigger programs need files with one job each, and data that’s still there the next time they run. In this course, you’ll get both by helping Dana Reyes with her budget tracker.

Dana’s tracker starts as one script, with her expenses typed into the code. Every new expense means editing the program, and any change it makes to the data while it runs is lost once it ends.

By the end of the course, it’s a program in several files, each with one job, and her expenses live in a JSON file, a plain text file that holds data outside the code.

When she runs it, the tracker adds November’s expenses, totals her spending, and tries a what-if budget, a changed copy of her monthly limits. Its last line proves that the copy left her real budget alone:

Language: Text
Added 3 expenses for 2026-11
By category: { groceries: 174, transport: 90, utilities: 72, fun: 98 }
By month: { '2026-10': 271, '2026-11': 163 }
Left: { groceries: 334, rent: 1200, utilities: 88, transport: 45, fun: 112 }
What-if left: { groceries: 284, rent: 1200, utilities: 88, transport: 45, fun: 162 }
Real budget unchanged: true

What You’ll Learn

By the end of this course, you’ll be able to:

  • Turn data into JSON text and back, fixing what JSON changes
  • Save a program’s data in a JSON file and load it again
  • Split a program into modules, with one job per file
  • Predict how modules load and what their importers share
  • Make deep copies and compare records value by value
  • Build a program in several files that keeps its data in JSON

Before You Start

You should already be able to write small Node programs with functions, arrays, and objects, and copy objects with spread. If this is your first course here, you haven’t missed anything, because Dana’s story starts in this course.

You’ll need a terminal, any editor, and a current LTS version of Node. The examples in this course ran on Node 26.

How the Course Works

Lessons are text or short video, and you type along in the Node REPL and in your own scripts. Each of the first three sections ends with a coding exercise that runs in your browser and is checked by tests. Then you’ll build Dana’s tracker as a project, explain it in a chat with the course’s mentor, and take a quiz.

First up is a text lesson, Write Data as JSON Text.

Download

Course Slides (.pdf)

452.2 KB
Download

Sample Code (.zip)

12.2 KB

00:00 Welcome to Modules and JSON: Programs Across Files. So far, your programs fit in one file. Bigger ones need files with one job each, and data that’s still there next time.

00:15 Here’s Dana Reyes’s budget tracker, as you’ll finish it. Each file has one job, and her expenses live in a JSON file, plain text that holds data outside the code.

00:26 When she runs it, it adds November’s expenses, totals her spending, and tries a what-if budget, a changed copy of her monthly limits. The last line proves the copy left her real budget alone.

00:40 It starts as one script, with her expenses typed into the code. Every new expense means editing the program. And an expense it adds while it runs is gone once it ends.

00:53 By the end, you’ll be able to turn data into JSON text and back, fixing what JSON changes. To save a program’s data in a JSON file and load it again. To split a program into modules, with one job per file.

01:07 To predict how modules load and what their importers share. To make deep copies and compare records value by value. And to build a program in several files that keeps its data in JSON.

01:20 You should already write small Node programs with functions, arrays, and objects, and copy objects with spread. If you’re new here, Dana’s story starts in this video.

01:31 You’ll need a terminal, an editor, and a current Node LTS. This course’s examples ran on Node 26.

01:41 Lessons are text or short video, and you type along in the Node REPL and your scripts. Each of the first three sections ends with a coding exercise in your browser, checked by tests.

01:51 Then you’ll build Dana’s tracker, explain it in a chat with the course’s mentor, and take a quiz. First up is the text lesson, Write Data as JSON Text.

Become a Member to join the conversation.