Problem Brief
Build an expense ledger tracking income/expense entries, computing live total income, total expenses, net balance, and supporting item deletion.
Requirements
- Add transactions via `[data-testid="tx-title"]`, `[data-testid="tx-amount"]`, `[data-testid="tx-type"]` (`income` | `expense`), and `[data-testid="add-tx"]`.
- Render `.tx-row` rows inside `[data-testid="tx-list"]` with a `.tx-delete` button.
- Live-compute `[data-testid="total-income"]`, `[data-testid="total-expense"]`, and `[data-testid="net-balance"]`.
- Deleting any `.tx-row` updates all three totals immediately.
Progressive Hints (2)
- Ignore invalid or non-positive (`<= 0`) amounts when adding.
- Recompute sums via `.reduce()` on every state change.
Reference Solution
Stuck? Load the verified reference code into your editor.
Automated Test Suite
5 Test Cases Ready- Initializes totals to 0Income, Expense, and Balance start at 0
- Adding income updates total-income and net-balanceAdding 5000 income yields balance 5000
- Adding expense updates total-expense and net-balanceAdding 1200 expense reduces net-balance to 3800
- Rejects negative or zero transaction amountsValidation ignores <= 0 amounts cleanly
- Deleting transaction recalculates totals immediatelyRemoving expense restores net-balance cleanly
Live Sandboxed Previewiframe sandbox