(e)
| 22 | |
| 23 | // Add transaction |
| 24 | function addTransaction(e) { |
| 25 | e.preventDefault(); |
| 26 | |
| 27 | if (text.value.trim() === '' || amount.value.trim() === '') { |
| 28 | alert('Please add a text and amount'); |
| 29 | } else { |
| 30 | const transaction = { |
| 31 | id: generateID(), |
| 32 | text: text.value, |
| 33 | amount: +amount.value |
| 34 | }; |
| 35 | |
| 36 | transactions.push(transaction); |
| 37 | |
| 38 | addTransactionDOM(transaction); |
| 39 | |
| 40 | updateValues(); |
| 41 | |
| 42 | updateLocalStorage(); |
| 43 | |
| 44 | text.value = ''; |
| 45 | amount.value = ''; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | // Generate random ID |
| 50 | function generateID() { |
nothing calls this directly
no test coverage detected