0
我在代碼頂部有兩個函數。在下面的while (i<1)
循環中,我稱之爲上述函數之一。此作品是第一次,但功能被稱之爲第二次顯示錯誤:調用循環中的函數,「未定義不是函數」
TypeError: undefined is not a function
下面是代碼:
var i = 0;
var newBalance = 0;
var deposit = function(amountIn)
{
newBalance = (newBalance + amountIn).toFixed(2);
};
var withdrawl = function(amountOut)
{
newBalance = (newBalance - amountOut).toFixed(2);
};
var choice = prompt("Would you like to access your account?").toLowerCase();
if (choice === "yes"){
while (i<1){
var inOrOut = prompt("Are you making a deposit or a withdrawl?").toLowerCase();
var strAmount = prompt("How much money are you trasfering?");
var amount = parseFloat(strAmount);
if (inOrOut === "deposit")
{
deposit(amount);
}
else if (inOrOut === "withdrawl")
{
withdrawl(amount);
}
else
{
console.log("You did not enter a valid number");
}
console.log("Your new balance is $" + newBalance);
var choiceTwo = prompt("Would you like to make another transaction?").toLowerCase();
if (choiceTwo === "no")
{
i = i + 1;
}
}
}
我衷心希望這不是一個真正的金融交易.... – briansol 2014-10-03 13:58:11