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

Method submitExpenseForm

assets/js/Budget.js:53–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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){

Callers 1

eventListenersFunction · 0.95

Calls 2

addExpenseMethod · 0.95
showBalanceMethod · 0.95

Tested by

no test coverage detected