我的问题是,当我第二次调用函数getMoney
之后检查我的总金额时。那告诉我错误的总数。我想投资我的帐户,加上我的新资金。
var cash = 1000;
var total = cash;
/*get money */
function getMoney() {
var Money = prompt("How much do you want to get money: ","0");
total = Number(cash) - Number(Money);
if(Money <= cash){
document.querySelector("#show").innerHTML = Money+" $ loading.";
var Print = confirm("Do you want to printer?");
var Time = setTimeout(function(){
if(Print==true) {
document.querySelector("#show").innerHTML = "Printer is preparing.";
} else {
document.querySelector("#show").innerHTML = "Thanks you for saving Natural.";
}
}, 3000);
} else {
document.querySelector("#show").innerHTML = "Total money"+cash+" No limit.";
}
}
function investIn() {
var investIn = prompt("How much do you want to invest in your account: ");
total = total + Number(investIn);
document.querySelector("#show").innerHTML = total + "your account..";
var Print = confirm("Do you want to printer?");
setTimeout(function() {
if(Print == true) {
document.querySelector("#show").innerHTML = "Before invest in: "+(total-Number(investIn))+"<br>"+" İnvest in total: "+invest+"<br>"+"After invest in total your account: "+total;
} else {
document.querySelector("#show").innerHTML = "Thanks you for saving Natural.";
}
}, 3000);
}
/* control money */
function accountBalance() {
document.querySelector("#show").innerHTML = total+" your account.";
}