在我选择选项 1 并添加像 100 这样的数字后,结果是这样的 100100
这是代码:
var userAmount;
var userMoney = 100;
var totalMoney;
alert("1. Add");
alert("2. Subtraction");
var userOption = prompt("Enter your selection: ");
if (userOption == 1) {
userAmount = prompt("Amount: ");
var totalMoney = userMoney + userAmount;
alert("Total is " + totalMoney);
}
else {
userAmount = prompt("Amount: ");
var totalMoney = userMoney - userAmount;
alert("Total is" + totalMoney);
}