@@ -25,6 +25,7 @@ function updateBalance() {
2525 const balance = transactions . reduce ( ( acc , transaction ) => {
2626 return transaction . type === "income" ? acc + transaction . amount : acc - transaction . amount ;
2727 } , 0 ) ;
28+ < << << << HEAD
2829
2930 totalIncome = transactions . reduce ( ( acc , transaction ) => {
3031 return transaction . type === "income" ? acc + transaction . amount : acc ;
@@ -34,6 +35,17 @@ function updateBalance() {
3435 return transaction . type === "expense" ? acc + transaction . amount : acc ;
3536 } , 0 ) ;
3637
38+ = === ===
39+
40+ totalIncome = transactions . reduce ( ( acc , transaction ) => {
41+ return transaction . type === "income" ? acc + transaction . amount : acc ;
42+ } , 0 ) ;
43+
44+ totalExpense = transactions . reduce ( ( acc , transaction ) => {
45+ return transaction . type === "expense" ? acc + transaction . amount : acc ;
46+ } , 0 ) ;
47+
48+ > >>> >>> a548c639afa0f1ac1cdb441c63180145b7acef31
3749 balanceAmount . textContent = balance . toFixed ( 2 ) ;
3850 incomeAmount . textContent = totalIncome . toFixed ( 2 ) ;
3951 expenseAmount . textContent = totalExpense . toFixed ( 2 ) ;
@@ -53,8 +65,13 @@ function addTransaction(event) {
5365 amount,
5466 type
5567 } ;
68+ < << << << HEAD
5669
5770
71+ = === ===
72+
73+
74+ >>> >>> > a548c639afa0f1ac1cdb441c63180145b7acef31
5875 transactions.push(transaction);
5976 if(type==="income"){
6077 totalIncome += amount ;
@@ -84,7 +101,11 @@ function deleteTransaction(index) {
84101 updateTransactions();
85102 updateBalance();
86103 saveTransactions();
104+ < << << << HEAD
87105
106+ = === ===
107+
108+ >>> >>> > a548c639afa0f1ac1cdb441c63180145b7acef31
88109}
89110
90111// Function to save transactions to Local Storage
@@ -138,21 +159,33 @@ function editTransaction(index) {
138159 amount : updatedAmount ,
139160 type : updatedType
140161 } ;
162+ << < << << HEAD
141163
164+ === = ===
165+
166+ >>> > >>> a548c639afa0f1ac1cdb441c63180145b7acef31
142167 if ( transaction . type === "income" ) {
143168 totalIncome -= transaction . amount ;
144169 totalIncome += updatedAmount ;
145170 } else if ( transaction . type === "expense" ) {
146171 totalExpense -= transaction . amount ;
147172 totalExpense += updatedAmount ;
148173 }
174+ < << << << HEAD
149175
176+ = === ===
177+
178+ >>> >>> > a548c639afa0f1ac1cdb441c63180145b7acef31
150179 transactions[index] = updatedTransaction;
151180 alert(`Transaction "${ updatedTransaction . description } " updated successfully!`);
152181 updateTransactions();
153182 updateBalance();
154183 saveTransactions();
184+ < << << << HEAD
155185
186+ = === ===
187+
188+ >>> >>> > a548c639afa0f1ac1cdb441c63180145b7acef31
156189 } else {
157190 alert ( "Invalid input! Please try again." ) ;
158191 }
0 commit comments