Project: Dana's Budget Tracker

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:

  1. Load expenses.json, with every date a Date and every amount a number.
  2. Add November’s expenses from november.json and save the whole list back as indented JSON.
  3. Add November only once, however often she runs the tracker.
  4. Print her totals by category and by month, and what’s left of her October limits.
  5. 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.js reads and writes the JSON files and is the only file that touches the disk.
  • report.js totals the spending and works out what’s left, with pure functions.
  • budget.js holds the budget, with makeWhatIf() from the last exercise beside it.
  • compare.js holds sameRecord(), the value-by-value comparison.
  • main.js is 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.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.