()
| 74 | |
| 75 | // Update the balance, income and expense |
| 76 | function 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 |
| 97 | function removeTransaction(id) { |
no outgoing calls
no test coverage detected