我不知道为什么我会收到这个错误。
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-");
答案 0 :(得分:2)
您错过了}
来关闭switch{...}
块。 “意外$end
”通常意味着您的括号/括号/括号级别未正确关闭。
答案 1 :(得分:0)
我不是一个javascript人员,但是您的开关正在打开{
并且您没有匹配的结束}