⭐ BONUS EXERCISE

EXERCISE 10: Personal Budget Tracker

Assignment

Create a personal budget tracker that:

  1. Creates an array of expense objects, each with:
    • description (string)
    • amount (number)
    • category (string: 'Food', 'Transport', 'Entertainment', 'Bills', etc.)
    • date (string)
  2. Creates a function called calculateTotalExpenses that:
    • Takes an array of expenses as parameter
    • Returns the total amount
  3. Creates a function called getExpensesByCategory that:
    • Takes an array of expenses and a category string as parameters
    • Returns the total amount spent in that category
  4. Creates a function called getHighestExpense that:
    • Takes an array of expenses as parameter
    • Returns the expense object with the highest amount
  5. Displays all expenses using forEach
  6. Displays the total expenses
  7. Displays expenses by category
  8. Displays the highest expense

Requirements:

  • Use arrays of objects
  • Use functions with parameters and return values
  • Use forEach, for loops, and comparison operators
  • Use template literals for formatting
  • Use an external JavaScript file (script.js) linked to your HTML

Create an index.html file and a script.js file with your solution.