Skip to content

Commit

Permalink
⌛ Pending 2 second for (loans/transfer)
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdelrahman-Adel610 committed Aug 31, 2024
1 parent 32113df commit 80aa7f9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,21 +223,25 @@ function transfer() {
let amount = Math.round(transAmount.value);
let from = activeAccount;
let toObj = accounts.find((i) => i.userName === to);
from && toObj && transferFromto(from, toObj, amount);
setTimeout(function () {
from && toObj && transferFromto(from, toObj, amount);
}, 2000);
transTo.value = "";
transAmount.value = "";
transAmount.blur();
transTo.blur();
}

function requestLoan() {
let amount = Math.round(loanAmount.value);
function checkLoan(amount) {
if (activeAccount.movements.some((i) => 0.1 * amount <= i)) {
activeAccount.movements.push(amount);
activeAccount.movementsDates.push(new Date().toISOString());
alert("Successful loan");
updateInterface(accounts.indexOf(activeAccount));
} else alert("Invalid loan");
}
function requestLoan() {
let amount = Math.round(loanAmount.value);
setTimeout(checkLoan, 2000, amount);
loanAmount.value = "";
loanAmount.blur();
}
Expand Down

0 comments on commit 80aa7f9

Please sign in to comment.