diff --git a/src/utils/transaction_utils.ts b/src/utils/transaction_utils.ts index b0584df..147056e 100644 --- a/src/utils/transaction_utils.ts +++ b/src/utils/transaction_utils.ts @@ -4,8 +4,7 @@ import {where} from "firebase/firestore"; export async function getCurrentBalance(user: User): Promise { const transactions = await getTransactions(user); - let balance = 0; - transactions.forEach(transaction => {balance += transaction.amount;}); + const balance = transactions.reduce((sum, transaction) => sum + transaction.amount, 0); return Math.round(balance * 100) / 100; }