JavaScript Study Projects
Three builds, each combining several chapters
Every project here is a runnable file in demo/practice/, linked from the Lab
Examples page. Read the walkthrough, predict the code, then open the file and confirm.
32 · The tested bank — node:test end to end
Combines: classes (09), error types (14), immutability habits (24), the
quality loop (25). An in-memory Account whose deposits and withdrawals throw
typed, user-facing errors — and a suite that pins every contract: happy paths,
RangeError types, message regexes, rejection handling, hooks for fresh state,
and a proof that no operation mutates the original. Run:
node --test roadmap/javascript/demo/practice/32_node_test_demo.js
Extend: add transfer() with an overdraft rule — tests first,
one at a time.
33 · The store counter — two architectures side by side
Combines: DOM building (13), events (13), state discipline (24). The same
counter written twice: on the left, the DOM is the state and a second counter
variable drifts from it; on the right, one state object with a history stack renders as a
pure consequence — and gets undo for free. Open it in a browser, break the left one from
the console, watch the right one refuse to lie. Extend: a third button
that resets, without touching the DOM outside render().
34 · The worker pool — parallelism you can time
Combines: workers and messaging (22), promises (20), pools (22). A
WorkerPool keeps N workers alive, queues jobs onto them, and resolves one
promise per job — the same shape as a browser pool, in Node's
worker_threads. Run it and compare wall time against the serial prediction.
Extend: a kill() that drains the queue on shutdown, tested
with a zero-length job list.
How to study it
Build each project twice: once following the walkthrough, once from a blank file with only the README-level goal. The second pass is where pattern vocabulary becomes instinct — and where the earlier phase demos stop feeling like separate lessons.