MCPcopy Create free account
hub / github.com/codemistic/Web-Development / updateValues

Function updateValues

Organisational Manager/assets/js/track.js:76–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

74
75// Update the balance, income and expense
76function updateValues() {
77 const amounts = transactions.map(transaction => transaction.amount);
78
79 const total = amounts.reduce((acc, item) => (acc += item), 0).toFixed(2);
80
81 const income = amounts
82 .filter(item => item > 0)
83 .reduce((acc, item) => (acc += item), 0)
84 .toFixed(2);
85
86 const expense = (
87 amounts.filter(item => item < 0).reduce((acc, item) => (acc += item), 0) *
88 -1
89 ).toFixed(2);
90
91 balance.innerText = `$${total}`;
92 money_plus.innerText = `$${income}`;
93 money_minus.innerText = `$${expense}`;
94}
95
96// Remove transaction by ID
97function removeTransaction(id) {

Callers 2

addTransactionFunction · 0.85
initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected