ARADPLAUG
ARADPLAUG

Reputation: 101

missing operand; found END

I don't know why I'm getting this error.

missing operand; found END

Whenever I make a new line, it appears at the bottom, so right now it's saying there's a problem with the last line.

Here is my code:

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

Upvotes: 0

Views: 1254

Answers (2)

nvoigt
nvoigt

Reputation: 77364

I'm not a javascript guy, but your switch is opening a { and you are not having a matching closing }

Upvotes: 0

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324820

You are missing the } to close your switch{...} blocks. "Unexpected $end" usually means you have levels of brackets/parentheses/braces that are not closed properly.

Upvotes: 2

Related Questions