Build a command-line personal finance tracker that manages income and expenses with proper tooling.
package.json[email protected].gitignore for node_modules/.prettierrc1. Data Structure (Objects & Arrays)
Create a transactions array containing at least 5 transaction objects:
const transactions = [
{
id: 1,
type: 'income',
category: 'salary',
amount: 3000,
description: 'Monthly salary',
date: '2025-01-15'
},
// ... more transactions
];
Each transaction must have: id, type (income/expense), category, amount, description, date.
2. Required Functions
Implement these functions using appropriate loops and array methods:
addTransaction(transaction) - Add new transaction to arraygetTotalIncome() - Sum all income using a loopgetTotalExpenses() - Sum all expenses using a loopgetBalance() - Calculate total income minus expensesgetTransactionsByCategory(category) - Filter transactions (use loop + push or indexOf/includes)getLargestExpense() - Find highest expense amountprintAllTransactions() - Display all transactions with formatting3. Display Requirements (Chalk)
Use chalk to color-code output:
4. Summary Report
Create a printSummary() function that displays:
5. Code Quality
for, for...of, while)💰 PERSONAL FINANCE TRACKER 💰
All Transactions:
1. [INCOME] Salary - €3000 (salary)
2. [EXPENSE] Rent - €1200 (housing)
3. [EXPENSE] Groceries - €300 (food)
4. [INCOME] Freelance - €500 (side-income)
5. [EXPENSE] Utilities - €150 (bills)
📊 FINANCIAL SUMMARY 📊
Total Income: €3500
Total Expenses: €1650
Current Balance: €1850
Largest Expense: Rent (€1200)
Total Transactions: 5
TBD
The HackYourFuture curriculum is licensed under CC BY-NC-SA 4.0 **
