-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeposit.js
22 lines (16 loc) · 939 Bytes
/
deposit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
document.getElementById('btn-deposit').addEventListener('click',function(){
const depositField = document.getElementById('deposit-field');
const newDepositAmountString = depositField.value;
const newDepositAmount = parseFloat(newDepositAmountString);
const depositTotalElement = document.getElementById('deposit-total');
const previousdepositTotalString = depositTotalElement.innerText;
const previousdepositTotal = parseFloat(previousdepositTotalString);
const currentDepositTotal = previousdepositTotal + newDepositAmount;
depositTotalElement.innerText = currentDepositTotal ;
const totalBalance = document.getElementById('balance-total');
const totalBalanceString = totalBalance.innerText;
const covtTotalBalance = parseFloat(totalBalanceString);
const finalBalance = newDepositAmount + covtTotalBalance;
totalBalance.innerText = finalBalance;
depositField.value ='';
})