你好,我试图做一个“选择你自己的冒险”游戏,但我得到这个错误。我似乎无法弄清楚如何解决这个问题,任何帮助将不胜感激 这是我到目前为止的编码,
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!");
}
答案 0 :(得分:0)
尝试这个我的代码(“非常快”)并鼓励在论坛上进行更多的研究,比如每件事情都已经完成,所以你可以告诉你做了这样的事情,而且,至少我服务证明是代码的一部分所以你可以看到什么在起作用,你的答案是怎样的,然后专门用来清理你的代码,如果一开始就没有气馁,那么这个开发,编码很快。
var age = prompt("how old are you?");
var userawnser;
//----------------------------------------------
//answer >=10
if (age >= 10) {
alert("you may proceed");
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"
);
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 do`enter code here`or 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"
);
} else {
alert("Sorry, what number you choice?");
}
confirm(
"never go places unprotected silly or your guts will be harvested again!"
);
if(confirm == false){
alert("that doesn't make any since!");
}
//------------------------------------------------------------------
//answer <=10(poor kid)
} else {
alert("I think you should leave, NOW");
}