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