From deedf1abcf2ac32476ab1cbfdae6903d7c78b205 Mon Sep 17 00:00:00 2001 From: Robert Lucas <100799838+Robert-M-Lucas@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:22:48 +0100 Subject: [PATCH] Small change --- src/utils/transaction_utils.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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; }