From 5d5c4af8f46f80a1174f51e4ca5262f812670dc6 Mon Sep 17 00:00:00 2001 From: Yash Rai <82558647+yashrai652@users.noreply.github.com> Date: Sat, 4 Nov 2023 09:56:42 +0530 Subject: [PATCH 1/2] Update expenditure-analysis.js --- 01-js/easy/expenditure-analysis.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/01-js/easy/expenditure-analysis.js b/01-js/easy/expenditure-analysis.js index 20fbb943..4185aa44 100644 --- a/01-js/easy/expenditure-analysis.js +++ b/01-js/easy/expenditure-analysis.js @@ -1,15 +1,26 @@ -/* - Implement a function `calculateTotalSpentByCategory` which takes a list of transactions as parameter - and return a list of objects where each object is unique category-wise and has total price spent as its value. - Transaction - an object like { itemName, category, price, timestamp }. - Output - [{ category1 - total_amount_spent_on_category1 }, { category2 - total_amount_spent_on_category2 }] - Once you've implemented the logic, test your code by running - - `npm run test-expenditure-analysis` -*/ function calculateTotalSpentByCategory(transactions) { - return []; + var spendEstimates ={}; + + for(var i =0; i Date: Sat, 4 Nov 2023 09:58:58 +0530 Subject: [PATCH 2/2] Update expenditure-analysis.js