Javascript 缺少操作数;收尾

Javascript 缺少操作数;收尾,javascript,Javascript,我不知道为什么会出现这个错误 missing operand; found END 每当我写新行时,它都会出现在底部,所以现在它说最后一行有问题 这是我的密码: alert("Hello, and welcome to [title undecided] by ARADPLAUG!"); alert("If there's a yes or no question, just say yes or no, no nah's or sure's or yup's or anything like

我不知道为什么会出现这个错误

missing operand; found END
每当我写新行时,它都会出现在底部,所以现在它说最后一行有问题

这是我的密码:

alert("Hello, and welcome to [title undecided] by ARADPLAUG!");
alert("If there's a yes or no question, just say yes or no, no nah's or sure's or yup's or anything like that.");
alert("You have four stat points to begin with. If you enter something wrong, you get -1 stat point.");
var choice1 = prompt("Choose one perk: STRENGTH, INTELLIGENCE, ENDURANCE, ALERTNESS or SPEED.").toLowerCase();
var choice2 = prompt("Choose one perk: STRENGTH, INTELLIGENCE, ENDURANCE, ALERTNESS or SPEED.").toLowerCase();
var choice3 = prompt("Choose one perk: STRENGTH, INTELLIGENCE, ENDURANCE, ALERTNESS or SPEED.").toLowerCase();
var beginning = prompt("You're running from a fire when you suddenly see a lake. Do you JUMP in it, keep RUNning, or FILL a bucket with it?").toLowerCase();
switch (beginning) {
    case 'run':
        alert("You run away from the scary water, into the safety of the fire. -YOU HAVE DIED-");
        break;
    case 'fill':
        var bucket = prompt("You have two buckets. Do you want to fill ONE or BOTH of them with water?").toLowerCase();
        break;
    case 'jump':
        if (choice1 === "alertness" || choice2 === "alertness" || choice3 === "alertness") {
            var branch = prompt("You jump into the water just in time. A branch above you looks like it's about to fall off. Do you want to SHAKE it off now and be alert or WAIT and hope it won't fall off?").toLowerCase();
        } else if (choice1 || choice2 || choice3 === "speed") {
            var cave = prompt("You jump out of the way just before a branch crushes you. It uncovers a hole leading to a cave. Do you enter it?");
        } else {
            alert("You look up, and see the branch fall just before it crushes your neck, killing you instantly. -YOU HAVE DIED- ");
        }
        break;
    default:
        alert("Sorry, that wasn't one of the options. The fire consumes you. -YOU HAVE DIED-");
        switch (branch) {
            case 'wait':
                if (choice1 === "speed" || choice2 === "speed" || choice3 === "speed") {
                    prompt("You jump out of the way just before the branch crushes you. It uncovers a hole leading to a cave. Do you enter it?");
                } else {
                    alert("You look up, and see the branch fall just before it crushes your neck, killing you instantly. -YOU HAVE DIED- ");
                }
                break;
            case 'shake':
                var cave2 = prompt("You shake the branch, causing it to fall. It uncovers a hole. Do you enter it?");
                break;
            default:
                alert("That wasn't one of the options. The branch falls and crushes you.  -YOU HAVE DIED-");

您缺少关闭
开关{…}
块的
}
。“意外的
$end
”通常意味着括号/圆括号/大括号的级别未正确关闭。

我不是javascript高手,但您的开关正在打开一个
{
,而您没有匹配的关闭
}

您缺少一个
}
。只需在末尾添加
}
。除了答案之外。调试这类事情的一个很好的工具是。您可以将代码复制到脚本部分,然后单击
JSHint
按钮,您可以看到消息
Missing'}'
,该行的左边有一个红点。这是一个很棒的工具,对我帮助很大,特别是它的自动格式化功能
TidyUp
对于查找缺少的大括号之类的东西非常有用。像IDE这样的工具或者一个好的IDE应该会发现错误。+1。我想外面的开关也少了一个。可能需要添加第二个
}
。不过我可能错了。