JavaScript AcademyProfessional Engineering

Level 3 · Interactive Web Applications Project 23 of 60 Runs in the browser

Project 23: Expense Tracking Dashboard

Log expenses with an accessible validated form, then see a dashboard of totals, category bars and budget warnings that updates from state.

Level 3 covers the DOM, events, forms, state and storage, so you write both files: the logic file holds pure state functions and app.js renders the state and handles events. Storage in the website's preview is memory-only; the downloaded project uses your browser's real localStorage.

1 · The problem

A user wants to log daily spending and see at a glance where the money goes and which category is over budget. The form must explain every mistake next to the field, and the dashboard must always agree with the table.

User stories

  • As a user, I want to log a coffee in seconds.
  • As a user, I want to see that I spent most on groceries.
  • As a user, I want a warning when I go over a budget.

2 · Requirements

  • Validate a new expense: description required, amount above 0, a known category and a date.
  • Show each error next to its field with aria-invalid and move focus to the first invalid field.
  • Render the expense table from state, newest date first, with a delete button.
  • Show the total and a bar per category, as a percentage of the largest category.
  • Warn when a category is over its budget.
  • Save to localStorage and load on start.

Acceptance criteria

  • The dashboard starts at $187.50 with Groceries the largest bar.
  • Submitting an empty form shows three errors and focuses Description.
  • Adding $50 of Fun pushes Fun over its $40 budget and shows a warning.

Architecture

LayerFileResponsibility
Pageindex.html + style.cssForm, table and dashboard.
Statetracker.jsValidation, totals, bars, budget checks. Your work.
View and eventsapp.jsRendering, form feedback, delete, storage. Your work.

Flow: Submit → validateExpense → errors? show + focus : expenses = [...expenses, e] → save → renderTable() + renderDashboard()

Expected result

Expense Tracking Dashboard: finished app
finished app

Screenshots are captured automatically from the solution by the browser test suite.

Build it: guided stages

Pick a stage, load its starter files, follow the steps, then run the app and the tests. Every stage is preserved separately, so loading one never overwrites another.

  1. Stage 1: Table and dashboard · Render the table and the dashboard from state.
  2. Stage 2: Accessible form · Validate input and explain every error next to its field.
  3. Stage 3: Budgets, delete and storage · Warn about budgets, delete expenses and keep them.

Troubleshooting

Errors stay after fixing a field.
Clear every field's message and aria-invalid on each submit, not only the invalid ones.
The amount is stored as text.
Convert with Number before storing; the form only gives strings.
The largest bar is not 100%.
Divide by the largest total, not by the overall total.

Extension challenges

  1. Filter the table by month.
  2. Edit the budgets in the page.
  3. Export the expenses as CSV.

Downloads

Browser projects open directly from index.html. Node.js unit tests: run node --test in the project folder.

AI development prompts

Context: I am building the academy's Expense Tracking Dashboard. Task: explain how to move focus to the first invalid field and why it matters. Constraints: explain the idea and point to the line that matters; do not write the whole solution. Expected behaviour: I can finish the stage myself. Testing: suggest two inputs that would show whether my code is right.
Context: My Expense Tracking Dashboard passes the visible tests. Task: check my form for accessibility problems. Constraints: do not rewrite my code; list issues in order of importance. Expected behaviour: I understand each issue and can fix it. Testing: give one test case per issue.
Context: I finished the Expense Tracking Dashboard. Task: help me plan this extension: filter by month. Constraints: keep the logic file free of page code; existing tests must still pass. Expected behaviour: a short plan with the functions to add or change. Testing: describe the new tests I should write first.

Source

Repository folder: projects/project-23-expense-tracking-dashboard/ · view on GitHub