Build a Savings Goal Tracker App with JavaScript
Saving money is easier when you can see the goal. A savings goal tracker lets you set a target — a new phone, a trip, an emergency fund — and watch a progress bar fill up as you add money. In this post, we build one with
Saving money is easier when you can see the goal. A savings goal tracker lets you set a target — a new phone, a trip, an emergency fund — and watch a progress bar fill up as you add money. In this post, we build one with plain JavaScript and localStorage, so your goals survive a page refresh.
The HTML is simple: a form to add a goal, and a list that shows each goal with a progress bar.
<form id="goal-form">
<input id="goal-name" placeholder="Goal name (e.g. New laptop)" required />
<input id="goal-target" type="number" placeholder="Target amount" required />
<button>Add goal</button>
</form>
<div id="goals"></div>
Each goal is an object with a name, a target, and a saved amount. We store the array in localStorage and render it on every change:
let goals = JSON.parse(localStorage.getItem('goals')) || [];
function save() {
localStorage.setItem('goals', JSON.stringify(goals));
render();
}
function render() {
document.getElementById('goals').innerHTML = goals
.map((goal, index) => {
const percent = Math.min(100, Math.round((goal.saved / goal.target) * 100));
return `
<div class="goal">
<h3>${goal.name}</h3>
<p>₹${goal.saved} of ₹${goal.target} — ${percent}%</p>
<div class="bar"><div style="width: ${percent}%"></div></div>
<button onclick="addMoney(${index})">+ ₹500</button>
</div>`;
})
.join('');
}
function addMoney(index) {
goals[index].saved += 500;
save();
}
document.getElementById('goal-form').addEventListener('submit', (e) => {
e.preventDefault();
goals.push({
name: document.getElementById('goal-name').value,
target: Number(document.getElementById('goal-target').value),
saved: 0,
});
save();
e.target.reset();
});
render();
A progress bar with a percentage does something a spreadsheet does not: it makes the goal feel close. You can extend this with a custom amount input instead of a fixed ₹500, a delete button, a target date with a "per week needed" calculation, or a small chart of your deposits over time.
Saving is as much about behaviour as it is about numbers — knowing why you spend and when you save matters more than the app itself. A good place to start thinking about that is The Psychology of Money, which explains how our habits and emotions shape our money decisions far more than spreadsheets do.
This app is a good first project because it combines forms, lists, calculations, and localStorage in about 60 lines — and you end up with something you might actually use every week.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.