Dana’s tracker has grown one piece at a time. It loads expenses.json and fixes the types, report.js totals her spending, and a what-if budget made with structuredClone() leaves her real one alone. Now November has started, and she wants all of it in one program she can run each month.
In this project, you’ll finish Dana’s tracker. You’ll read what she needs it to do, see which file each part belongs in, and build it in steps that the next exercises check as you go. Every piece is one you’ve met in this course, so the work is in fitting them together.
Read Dana’s Brief
A brief says what a program must do before anyone decides how. Dana’s brief is short. When she runs node main.js in her budget-tracker folder, the tracker should do five things:
- Load
expenses.json, with every date aDateand every amount a number. - Add November’s expenses from
november.jsonand save the whole list back as indented JSON. - Add November only once, however often she runs the tracker.
- Print her totals by category and by month, and what’s left of her October limits.
- Try a what-if with groceries at 400 and fun at 200, and show that her real budget is unchanged.
The last point matters most to Dana. She wants to play with numbers without any risk to the plan she actually follows. So the tracker has to print proof that the real budget survived.
Each part has a home in the files you already have. The project keeps the jobs you gave the files earlier in this course:
load.jsreads and writes the JSON files and is the only file that touches the disk.report.jstotals the spending and works out what’s left, with pure functions.budget.jsholds the budget, withmakeWhatIf()from the last exercise beside it.compare.jsholdssameRecord(), the value-by-value comparison.main.jsis the thin entry point that imports, calls, saves, and prints.
If a file is missing, copy it from the lesson where you wrote it. Your makeWhatIf() lives in the exercise editor, so copy it from there into budget.js. The whatif.js script from comparing budgets was a tryout. main.js takes over its job, so you can delete it. package.json and expenses.json stay as they are.