MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / updateValues

Function updateValues

assets/js/ExpenseTracker.js:84–104  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

82
83 //Update the balance income and expence
84 function updateValues() {
85 const amounts = transactions.map(
86 (transaction) => transaction.amount
87 );
88 const total = amounts
89 .reduce((acc, item) => (acc += item), 0)
90 .toFixed(2);
91 const income = amounts
92 .filter((item) => item > 0)
93 .reduce((acc, item) => (acc += item), 0)
94 .toFixed(2);
95 const expense =
96 (amounts
97 .filter((item) => item < 0)
98 .reduce((acc, item) => (acc += item), 0) *
99 -1).toFixed(2);
100
101 balance.innerText=`$${total}`;
102 money_plus.innerText = `$${income}`;
103 money_minus.innerText = `$${expense}`;
104 }
105
106
107 //6

Callers 2

addTransactionFunction · 0.85
InitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected