Capstone · JavaScript Programming (language in depth)
Capstone: Hisaab-Kitaab, a trip expense splitter
The brief
Four friends went to Goa and nobody knows who owes whom. Build Hisaab-Kitaab, a library and command-line tool: an Expense class with fair paise-exact shares, a parser for plain sentences like "Ravi paid 1350 for dinner split Asha, Ravi, Priya", balances, the fewest sensible transfers to settle up, rupee formatting, saving trips as JSON, currency conversion for trips abroad, a running balance generator, and a Node.js CLI with a test suite.
Why it matters
Splitting group expenses is a real product (Splitwise has millions of users) and a favourite interview problem, because it touches everything: data modelling, exact money maths, parsing text, algorithms, async code and testing. It makes a strong portfolio piece: a small, complete, tested npm-style package with a CLI.
Skills you practise
- classes and validation
- fair rounding in paise
- regular expressions with named groups
- Map-based balances
- a greedy settle-up algorithm
- Intl currency formatting
- JSON with versioning
- async conversion with shared promises
- generators
- Node.js fs and process.argv
- node --test
You need
- Node.js 20 or newer
- A GitHub account for the finished repository
What you will have at the end
Hisaab-Kitaab: a tested JavaScript package (splitter.js, split.js, tests and a README) that settles group trips exactly to the paisa.
How it is marked (rubric, 100 points)
| Works correctlyEvery check passes; the CLI prints the right settlement. | 30 |
|---|---|
| Exact money handlingPaise everywhere, leftover paise shared fairly, balances that add up to 0. | 20 |
| DesignA validated class, pure functions, an injected rate source, a generator for lazy results. | 20 |
| TestingYour own tests cover the tricky cases and pass with npm test. | 15 |
| PresentationA clear README and a repository you can walk through in an interview. | 15 |
0/10 steps done
Step 1 of 10
An Expense with fair shares
new Expense({ paidBy, amountPaise, description, sharedBy }) checks its data (a payer, a whole number of paise above 0, at least one person, nobody twice), and shares() returns a Map of each person's share in paise that adds up exactly, with any leftover paise going one each to the first people listed.
Money is whole paise, so ₹1,000 shared by 3 cannot be 333.333… each. Give everyone the floor of the division, then hand the leftover paise (the remainder) one each to the first people in the list: 33,334 + 33,333 + 33,333 = 1,00,000 paise. The shares always add up to the expense, so balances never drift by a paisa.
The constructor refuses bad data, so every Expense in the program is valid.
Run shows what your code prints. Check runs the step's tests. Ctrl+Enter checks too.