【发布时间】:2015-01-25 05:07:53
【问题描述】:
您好,我正在尝试制作“选择您自己的冒险”游戏,但出现此错误。我似乎无法弄清楚如何解决这个问题,任何帮助将不胜感激 这是我到目前为止的编码,
var age = prompt("how old are you?");
if (age > 10) {
alert("you may proceed");
} else; {
alert("I think you should leave, NOW");
}
alert(
"you are in a small room sitting in a desk. there is a door right behind you PLEASE NOTE the apocalypses has just started there are only a few people in your building alive think about finding a weapon"
);
var userawnser = prompt(
"Do you 'type 1 to' examine the room or '2' exit through the door?"
);
if (userawnser = 1) {
alert(
"You see a stapler on your desk a bat by the door and a computer.You grab the bat"
);
} else if (userawnser = 2); {
alert(
"you walk outside of you room and are surprise attacked by a zombie"
);
alert(
"you attempt to get the zombie off but since it got you by surprise you are bitten in the back of the neck and join the undead army"
);
confirm(
"never go places unprotected silly or your guts will be harvested again!"
);
} else; {
alert("that doesn't make any since!");
}
【问题讨论】:
-
您有一个错字(
else之后的额外;)。你的代码还有很多很多其他问题,比如使用=而不是==(这会破坏整个事情),严重缺乏缩进,任意空格等。我建议你去找一个好的@ 987654321@. -
在测试相等性时使用
==,而不是=。 -
不要将
;放在else或if语句中的测试子句之后。 -
"that doesn't make any since!"- 是的,没错。
标签: javascript debugging