()
| 51 | } |
| 52 | //submit expense form |
| 53 | submitExpenseForm(){ |
| 54 | const expenseValue = this.expenseInput.value; |
| 55 | const amountValue = this.amountInput.value; |
| 56 | if(expenseValue === '' || amountValue === '' || amountValue < 0){ |
| 57 | this.expenseFeedback.classList.add('showItem'); |
| 58 | this.expenseFeedback.innerHTML = `<p>values cannot be empty or negative</p>`; |
| 59 | const self = this; |
| 60 | setTimeout(function(){ |
| 61 | self.expenseFeedback.classList.remove('showItem'); |
| 62 | }, 3000) |
| 63 | } else { |
| 64 | let amount = parseInt(amountValue); |
| 65 | this.expenseInput.value = ''; |
| 66 | this.amountInput.value = ''; |
| 67 | |
| 68 | let expense = { |
| 69 | id: this.itemID, |
| 70 | title: expenseValue, |
| 71 | amount: amount |
| 72 | } |
| 73 | this.itemID++; |
| 74 | this.itemList.push(expense); |
| 75 | this.addExpense(expense); |
| 76 | this.showBalance(); |
| 77 | |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | //add expense |
| 82 | addExpense(expense){ |
no test coverage detected