From 153f2e5d78daeb717bdbfb6ef6af9e08c3d43dba Mon Sep 17 00:00:00 2001 From: Faizan Khan Date: Sat, 13 Jul 2024 12:59:22 +0530 Subject: [PATCH 1/2] changes --- js/banking.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/js/banking.js b/js/banking.js index ff6e4ae..a257e88 100644 --- a/js/banking.js +++ b/js/banking.js @@ -1,22 +1,25 @@ document.getElementById("deposit-btn").addEventListener("click", function () { const depositInput = document.getElementById("deposit-input"); - if(depositInput === '' || isNaN(depositInput)){ - alert('Input Filed Empty or Enter valid number.'); + const depositInputValue = depositInput.value; + if(depositInputValue === '' || isNaN(depositInputValue)){ + alert('Input Field Empty or Enter valid number.'); return; } const depositText = document.getElementById("deposit-text"); const currentDepositText = depositText.innerText; - const depositInputValue = depositInput.value; - depositText.innerText = + const updatedDepositText = parseFloat(currentDepositText) + parseFloat(depositInputValue); + depositText.innerText = updatedDepositText; depositInput.value = ""; - const balanceText = document.getElementById("balance-text"); const updatedBalance = parseFloat(depositInputValue) + parseFloat(balanceText.innerText); balanceText.innerText = updatedBalance; }); +// console.log(document.getElementById('deposit-input')); + + document.getElementById("withdraw-btn").addEventListener("click", function () { const withdrawInput = document.getElementById("withdraw-input"); const currentWithdrawInput = withdrawInput.value; From 2f6ad151e635cc299f85b05d81a4d71cc16d8c80 Mon Sep 17 00:00:00 2001 From: Faizan Khan Date: Sat, 13 Jul 2024 16:21:22 +0530 Subject: [PATCH 2/2] changes --- js/banking.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/js/banking.js b/js/banking.js index a257e88..e5d2d5a 100644 --- a/js/banking.js +++ b/js/banking.js @@ -17,9 +17,6 @@ document.getElementById("deposit-btn").addEventListener("click", function () { balanceText.innerText = updatedBalance; }); -// console.log(document.getElementById('deposit-input')); - - document.getElementById("withdraw-btn").addEventListener("click", function () { const withdrawInput = document.getElementById("withdraw-input"); const currentWithdrawInput = withdrawInput.value;