javascript - 缺少操作数;找到END

标签 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 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-");

最佳答案

您缺少用于关闭 switch{...} block 的 }。 “Unexpected $end”通常意味着括号/圆括号/大括号的级别未正确关闭。

关于javascript - 缺少操作数;找到END,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15659209/

相关文章:

javascript - Vue CLI 生成空正文,错误为 : Cannot find element: #app after migration vuecli 2>3

javascript - HTML Canvas 尺寸过大

javascript - 为什么在点击事件后要弹出几次警告?

javascript - 如何将 ResultSet 转换为 JSON 对象

javascript - 如何使用 jQuery 禁用/启用 jQueryUI 日期选择器?

javascript - 使用 JavaScript 将换行符写入 <span> 元素?

javascript - CSS 悬停在 JQuery 循环的最后一条记录中不起作用

javascript - 在 JavaScript 中从正则表达式生成字符串

javascript - 为什么 Canvas.FillText 方法似乎使用了错误的坐标?

javascript - React - 如何打开 PDF 文件作为 href 目标空白