JavaScript Curriculum
Everything Together
hardThis is the chapter final. A real-world JavaScript program — not a toy — that wires every concept you've learned into something that does meaningful work. When you finish, you'll have written code that looks like the code in production Nexus, styled to the same standards, tested against the same criteria.
Nineteen lessons. One program.
Every feature of Chapter 01 JavaScript was introduced in isolation — a concept, a component, a small challenge. This lesson asks you to use them together, the way you'll use them in every real project you work on.
Here's the map of everything you've learned and how it connects:
Click any concept to see what it depends on and what it unlocks.
Click each concept to see what it depends on and what it unlocks. The capstone sits at the bottom of the graph — it depends on everything.
What you're building
A UserRegistry — a class-based system that manages a list of users with validation, functional processing, regex-based name checking, and localStorage persistence.
This is not a contrived exercise. Every element maps directly to a real-world pattern:
| Feature | Lesson | Real-world analog |
|---|---|---|
Class with #users | 16 | Entity repositories, data models |
| Input validation with throw | 10 | API request validation |
| Regex name check | 18 | Form field validation |
| Sort + filter + map chain | 17 | Dashboard data processing |
| JSON.stringify to localStorage | 19 | Settings persistence, offline cache |
| Static factory from storage | 15/16 | Hydration from persisted state |
Optional chaining + ?? | 13 | Safe config and data access |
Architecture walkthrough
Before you write the code, read the structure:
Key patterns explained
Private fields keep state safe
Two-layer validation — structural then semantic
The two layers are separated because they're different kinds of errors — structural failure vs business-rule failure. Callers can catch them separately if needed.
Functional pipeline in a method
slice(0, n) after sort takes the top n. The spread copy protects the private array from sort's in-place mutation.
Static factory method — restoring state
This is the factory pattern — a static method that constructs and returns an instance with a specific setup. Cleaner than putting complex initialisation logic in a constructor.
Putting it together — complete test
This is what JavaScript looks like in production
Classes encapsulate data and behaviour. Private fields prevent accidental mutation. Validation throws meaningful errors. Functional pipelines express transformations clearly. Static factories restore state from persistence. Regex handles format validation inline.
None of this is exotic. All of it is expected. Chapter 01 is complete.
Challenge
Build a UserRegistry class with: a #users private field (array). An add(user) method that validates the user object has name (string) and score (number ≥ 0) — throws 'Invalid user' if not. Uses regex /^[a-zA-Z\\s]{2,}$/ to validate that name contains only letters and spaces (min 2 chars) — throws 'Invalid name' if not. A getTopUsers(n) method that returns the top n users sorted by score descending, mapped to 'name (score)' strings. A saveToStorage(key) method that JSON.stringifies the users array into localStorage. A static loadFromStorage(key) method that reads from localStorage, parses the JSON, re-validates each entry, and returns a new UserRegistry populated with the valid entries (skipping invalid ones silently). Test: create a registry, add at least 3 users, call getTopUsers(2), save to storage, load back and verify.
Everything Together
hardThis is the chapter final. A real-world JavaScript program — not a toy — that wires every concept you've learned into something that does meaningful work. When you finish, you'll have written code that looks like the code in production Nexus, styled to the same standards, tested against the same criteria.
Nineteen lessons. One program.
Every feature of Chapter 01 JavaScript was introduced in isolation — a concept, a component, a small challenge. This lesson asks you to use them together, the way you'll use them in every real project you work on.
Here's the map of everything you've learned and how it connects:
Click any concept to see what it depends on and what it unlocks.
Click each concept to see what it depends on and what it unlocks. The capstone sits at the bottom of the graph — it depends on everything.
What you're building
A UserRegistry — a class-based system that manages a list of users with validation, functional processing, regex-based name checking, and localStorage persistence.
This is not a contrived exercise. Every element maps directly to a real-world pattern:
| Feature | Lesson | Real-world analog |
|---|---|---|
Class with #users | 16 | Entity repositories, data models |
| Input validation with throw | 10 | API request validation |
| Regex name check | 18 | Form field validation |
| Sort + filter + map chain | 17 | Dashboard data processing |
| JSON.stringify to localStorage | 19 | Settings persistence, offline cache |
| Static factory from storage | 15/16 | Hydration from persisted state |
Optional chaining + ?? | 13 | Safe config and data access |
Architecture walkthrough
Before you write the code, read the structure:
Key patterns explained
Private fields keep state safe
Two-layer validation — structural then semantic
The two layers are separated because they're different kinds of errors — structural failure vs business-rule failure. Callers can catch them separately if needed.
Functional pipeline in a method
slice(0, n) after sort takes the top n. The spread copy protects the private array from sort's in-place mutation.
Static factory method — restoring state
This is the factory pattern — a static method that constructs and returns an instance with a specific setup. Cleaner than putting complex initialisation logic in a constructor.
Putting it together — complete test
This is what JavaScript looks like in production
Classes encapsulate data and behaviour. Private fields prevent accidental mutation. Validation throws meaningful errors. Functional pipelines express transformations clearly. Static factories restore state from persistence. Regex handles format validation inline.
None of this is exotic. All of it is expected. Chapter 01 is complete.
Challenge
Build a UserRegistry class with: a #users private field (array). An add(user) method that validates the user object has name (string) and score (number ≥ 0) — throws 'Invalid user' if not. Uses regex /^[a-zA-Z\\s]{2,}$/ to validate that name contains only letters and spaces (min 2 chars) — throws 'Invalid name' if not. A getTopUsers(n) method that returns the top n users sorted by score descending, mapped to 'name (score)' strings. A saveToStorage(key) method that JSON.stringifies the users array into localStorage. A static loadFromStorage(key) method that reads from localStorage, parses the JSON, re-validates each entry, and returns a new UserRegistry populated with the valid entries (skipping invalid ones silently). Test: create a registry, add at least 3 users, call getTopUsers(2), save to storage, load back and verify.