I Know What I Need, But I Don't Know How To Build It
Pick the thing you need. Then derive it: meaning, state, operations, rules, examples, representation, pseudocode — and only then the code, one rung at a time.
“I know I need a shopping cart. I have no idea how to implement a shopping cart.” The gap is not a missing tutorial; it is a missing method. Every stage below asks you to write before it shows you anything, because the code is the last step of a derivation, not the first thing to search for.
Which concept?
Grouped by exercise level; the level is how far the derivation goes, not how hard the code is.
How much help?
Every stage's content is shown right after your attempt box.
Counter — twelve stages
I need a like button. It shows a number and the number goes up when you click it. I do not know how to keep the number.
Define the concept
In one sentence, without any code: what is it? Then answer for yourself — does it have identity, who owns it, how long does it exist, should it survive a reload or a login?
Counter = A single whole number that records how many times something has happened and can be moved up, moved down, reset and read.
- Does a counter have identity? Only through what it counts. Two counters both reading 7 are different counters if one counts likes on post A and the other likes on post B. In memory the variable is the identity; the moment there are two, each needs a name or a key.
- Who owns it? The thing being counted — a post, a page, a game score. In V0 nobody: it is one number in one process. The owner appears with the second counter.
- How long does it exist? As long as the thing it counts. A page-view counter lives as long as the page; a score lives as long as the game. V0 says "as long as the process", which is a persistence decision waiting to be made.
- Should it survive reload? A like count that resets when you refresh is a bug the user sees immediately, so usually yes. A stopwatch lap counter — usually no. The concept is the same; only where it lives differs.
- Should it survive login? A shared counter (likes) belongs to the post, not the viewer, so login is irrelevant to it. A personal counter (your streak) belongs to the user and follows them. Which one you have decides the owner field.
The catalog is one derivation, not the only one (impl §60). A different set of examples yields different rules; a different first requirement yields a different V1; a map instead of an array is not wrong, only an answer to a different question. Compare your derivation with the reference for the differences, then decide which ones were rules and which were style.
Take it further
The flagship exercise: the cart typed by you, with the reference hidden until you ask.
Make It Smaller Until You Know How to Build It →The principle behind the ladder, and the primitive chain it produces.
The Implementation Loop →The loop the twelve stages follow, and why the code is last.