Javascript 当我想从取款输入中添加余额时的编码问题

Javascript coding problem when I want to add balance from withdraw input

我试图在点击取款按钮时更改取款余额。但是当我点击提款按钮时,只有提款金额发生变化。问题出在哪里?存款按钮工作正常。请检查我的代码。 代码 link : https://basir5101.github.io/ta-ta-bank/ 存储库 link:https://github.com/basir5101/ta-ta-bank/blob/master/index.html/

提款时,您正在更新提款钱包金额,这是完美的,但您没有更新 currentBalance 钱包。在更新提款时添加了用于更新当前余额的额外行,现在可以正常工作了:

withdrawButton.addEventListener('click', function(){
    const withdrawInput = document.getElementById('withdrawInput').value;
    const withdrawInputNumber = parseFloat(withdrawInput);
    console.log(withdrawInputNumber);
    balance('currentWithdraw', withdrawInputNumber);
    balance('currentBalance', withdrawInputNumber);

    document.getElementById('withdrawInput').value = "";
})