Lesson 21 — Closure factories
Functions that make functions
A factory is a function that builds and returns another function, set up with some value. adder(10) returns a new function that adds 10 to whatever you give it — the 10 is remembered by closure.
const add10 = adder(10);
add10(5); // 15
Why it matters: you can create many specialised helpers (tax calculators, formatters, validators) from one template.
Write multiplier(m) that returns (x) => x * m, then use it to make double and triple.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based JavaScript Foundations courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for JavaScript Foundations books — check the publication year so the examples match current versions.
Search Amazon →