期待一个标识符,但找到'其他'

时间:2015-01-25 05:07:53

标签: javascript debugging

你好,我试图做一个“选择你自己的冒险”游戏,但我得到这个错误。我似乎无法弄清楚如何解决这个问题,任何帮助将不胜感激 这是我到目前为止的编码,

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!");
}

1 个答案:

答案 0 :(得分:0)

朋友,我解决了这个问题(抱歉我的英语不好)。 我发现你在最后的其他地方有一个“;”,至少会产生这些结束的错误:else ;.那不对,但我应该独自一人:“别的” 现在,想一想quedaria你的答案的顺序,说你想要1(真实)直接发送给你的游戏。现在,如果那是2(“我们知道那个可怜的家伙不能玩的东西),代码会自动告诉你你不能在那里玩并完成这件事,而不是如果我解释得好。

尝试这个我的代码(“非常快”)并鼓励在论坛上进行更多的研究,比如每件事情都已经完成,所以你可以告诉你做了这样的事情,而且,至少我服务证明是代码的一部分所以你可以看到什么在起作用,你的答案是怎样的,然后专门用来清理你的代码,如果一开始就没有气馁,那么这个开发,编码很快。

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");
}