Family Finance Coordinator
Family Finance Coordinator
";
return;
}
// Add family's financial data
familyFinanceData.push({
familyMember: familyMember,
income: income,
expenses: {
housing: housing,
groceries: groceries,
transportation: transportation,
utilities: utilities,
healthcare: healthcare,
other: otherExpenses
},
savingsGoal: savingsGoal
});
// Generate financial overview
var totalIncome = familyFinanceData.reduce((total, member) => total + member.income, 0);
var totalHousing = familyFinanceData.reduce((total, member) => total + member.expenses.housing, 0);
var totalGroceries = familyFinanceData.reduce((total, member) => total + member.expenses.groceries, 0);
var totalTransportation = familyFinanceData.reduce((total, member) => total + member.expenses.transportation, 0);
var totalUtilities = familyFinanceData.reduce((total, member) => total + member.expenses.utilities, 0);
var totalHealthcare = familyFinanceData.reduce((total, member) => total + member.expenses.healthcare, 0);
var totalOtherExpenses = familyFinanceData.reduce((total, member) => total + member.expenses.other, 0);
var totalSavingsGoal = familyFinanceData.reduce((total, member) => total + member.savingsGoal, 0);
var totalExpenses = totalHousing + totalGroceries + totalTransportation + totalUtilities + totalHealthcare + totalOtherExpenses;
var remainingForSavings = totalIncome - totalExpenses;
// Display results in a table
result.innerHTML = `
Family Financial Overview
| Category |
Total Amount ($) |
| Total Family Income |
$${totalIncome.toFixed(2)} |
| Total Housing Expenses |
$${totalHousing.toFixed(2)} |
| Total Groceries Expenses |
$${totalGroceries.toFixed(2)} |
| Total Transportation Expenses |
$${totalTransportation.toFixed(2)} |
| Total Utilities Expenses |
$${totalUtilities.toFixed(2)} |
| Total Healthcare Expenses |
$${totalHealthcare.toFixed(2)} |
| Total Other Expenses |
$${totalOtherExpenses.toFixed(2)} |
| Total Monthly Expenses |
$${totalExpenses.toFixed(2)} |
| Total Savings Goal |
$${totalSavingsGoal.toFixed(2)} |
| Remaining for Savings |
$${remainingForSavings.toFixed(2)} |
`;
});