-8

我是新手好吗?我只是不明白我的代码有什么问题,如果有人可以修复它,请向我解释...

代码:

<script>
var userMoney:10;
var userChoice = prompt("Okay young lad, you've got 3 choices, either you choose box 1,      2 or 3");
if(userChoice==="1"){
confirm("Wow. You're just that lucky, you've got 10$ added to your account");
}
if(confirm("Wow. You're just that lucky, you've got 10$ added to your account"){
userMoney:10+10;
}
var yesno = prompt("Would you like to see how much money you've got lad?");
if(yesno==="yes"){
confirm(userMoney)
} else {
confirm("Well lad I Guess that's the end of the game.");
}
if(userChoice==="2"){
confirm("Oi, bad luck Brian better luck next time");
}
if(userChoice==="3"){
confirm("Oi, bad luck Brian better luck next time");
}
</script>
4

3 回答 3

3
var userMoney:10;

应该var userMoney = 10;

userMoney:10+10;

可能是:userMoney = userMoney + 10;userMoney += 10;

于 2013-07-23T20:39:03.970 回答
2

您的第一行应为:

var userMoney=10;

您在几个地方使用了 : 而不是 = 。

此外,将来,使用http://jsfiddle.net/之类的工具来查看您的脚本

于 2013-07-23T20:38:29.773 回答
0

更改用户货币=10+10;并更改 userMoney=10

于 2013-07-23T20:41:33.130 回答