5. Logical Operator Syntax Break error


#1


5. Logical Operators


SyntaxError: Illegal break statement

Oops, try again. There was a problem with your syntax.

Replace this line with your code. 
var user = prompt("What race are you adventurer? THIEF, MAGE, OR WARRIOR?").toUpperCase();
switch(user) {
    case 'THIEF':
        console.log("Would you like to purchase a bow?");
        var steal = prompt("Are you going to STEAL, and or PURCHASE the bow from the seller?").toUpperCase;
        if (steal === "STEAL" || purchase === "PURCHASE") {
            console.log("It would be kinda hard to do that");
        } else if (steal === 'PURCHASE') {
            console.log("The seller gives it to you telling you that he wanted to do a good deed for the day");
           } else {
                console.log("I don't know what that means.");
            }
        }
        break;
        case 'MAGE':
            console.log("Would you like to purchase a spellbook?");
            var spell = prompt("Are you going to buy a FIRE, and or an ICE book?").toUpperCase;
            if (spell === "FIRE" && spell === "ICE") {
                console.log("You burned the seller and yourself testing out the book, nice.");
            } else if(spell === "ICE") {
                console.log("You didn't hurt anyone, good job.");
            } else {
                console.log("I don't know what that means.");
            }
            break;
            case 'WARRIOR':
                console.log("Would you like to purchase a sword?");
                var buy = prompt("Are you going to buy a LONG sword, or a SHORT sword?").toUpperCase;
                if (buy === "LONG") {
                    console.log("You can't handle it's length, money wasted.");
                } else if(buy === "SHORT") {
                    console.log("It's length is perfect for you!");
                } else {
                    console.log("I don't know what that means.");
                }
                break;
                default:
                console.log("I don't know of that race.");
}


#2

Here

You ended the switch with that last curly bracket before break; remove it.


#3

tanks vrrrrry much much much much


#4

Now I have an error saying, "Unexpected token case."


#5

Okay, please post new code.

Thank you! :slight_smile:


#6

If the steal prompt only takes one input, why have a condition checking for 2 inputs?

Where is the purchase prompt?


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.