Duration: 90 minutes (in-workshop exercises)
Focus: Using closures to persist state across calls, guided by APS (Approach to Problem Solving).
You will work through three problems in problems/:
addByX.js(APS review)callTimes.js(pairs)saveOutput.js(trios)
Each file contains:
- A student-facing prompt at the top
- A starter function
- An optional
runTests()function that you can uncomment locally
Tip: Use the APS steps as you work (Define success → Explore key phrases → Match actions → Redefine if needed → Create strategy).
- Codespaces or local: open the repo in VS Code.
- Open a problem file in
problems/. - Fill in the function body.
- Uncomment the
runTests()call at the bottom to try your solution.
- Combine adders from
addByX: Write a function that takes twoaddByXfunctions (likeaddByTwoandaddByThree) and returns a new function that adds both amounts. - Make
callTimesresettable: Add functionality to reset the counter back to zero. - Extend
saveOutput: Support functions that take multiple arguments.
Workshop Expectation: For each problem, run the minimal examples provided, then add ONE of your own test call(s) to validate your solution (edge case or independent instance). Keep it short — you have ~20 minutes per challenge.