This repo provides three beginner‑friendly JavaScript katas with tests so learners can practice loops, conditionals, and nested loops and verify their solutions.
Before you start, fork this repository to your own GitHub account. No dependencies are required beyond Node.js. Then clone your fork and open the folder in your editor.
- Open the kata file you’re working on (see list below).
- Replace the
throw new Error('Not implemented')line with your solution. - Run the tests to check your work.
Required commits per kata: scaffold → feature → refactor (see the Commit workflow section below).
- Include short comments that explain your logic choices (why you chose a loop, condition, or data shape).
- Keep the
globalThis.__kataslines intact so tests can import your function.
From the repository root (Programming1-ControlFlow-v2), run:
cd js-katas
npm test
If your terminal is already inside js-katas, run:
npm test
Katas:
- Loops kata:
katas/loops.js— first N even numbers. - Conditions kata:
katas/conditions.js— FizzBuzz style exercise. - Nested kata:
katas/nested.js— multiplication table (nested loops).- Example:
multiplicationTable(3)should return[[1,2,3],[2,4,6],[3,6,9]]. - Edge case: sizes less than 1 should throw an error.
- Example:
- Tests will fail until learners implement the kata functions (they currently throw
Not implemented). - Don’t remove or rename the
globalThis.__kataslines in the kata files — the tests use them to import your functions.
For each kata, make three commits in order:
- Scaffold — open the kata file and add the basic function structure.
- Feature — implement the working solution so tests pass.
- Refactor — clean up variable names or structure without changing behavior.
Example commit messages:
scaffold: add firstNEven structurefeature: implement firstNEven logicrefactor: simplify loop in firstNEven