"Illegal break" help me please!


#1


SyntaxError: Illegal break <==statement please help me !


confirm("If you are readdy to play click on OK.");
var health = 10
var energy = 10
console.log("DAY 1");
console.log("HEALTH = " + health);
console.log("ENERGY = " + energy);
console.log("You have found the chest.");

var user = prompt("OPEN, DO NOT OPEN, SAVE FOR LATER").toUpperCase();
switch(user) {
    case "OPEN":
        console.log("Opening chest.");
        var energy = energy - 1
        console.log("ENERGY = " + energy);
        console.log("You can t because that chest need key.");
        var key = prompt("SEARCH FOR KEY, DO NOT SEARCH").toUpperCase();
        switch(key) {
            case "SEARCH FOR KEY":
                console.log("Searching... Searching... Oh you have found it! but you have found sider too!");
                var spider = prompt("FIGHT, RUN, SCREAM");
                    switch(spider) {
                        case "FIGHT":
                        var slaying = true;
                        var youHit = Math.floor(Math.random() * 2);
                        var damageThisRound = Math.floor(Math.random() * 5 + 1);
                        var totalDamage = 0;                        
                        while (slaying) {
                          if (youHit) {
                            console.log("You hit the spider and did " + damageThisRound + " damage!");
                            totalDamage += damageThisRound;                         
                            if (totalDamage >= 5) {
                              console.log("You did it! You slew the spider!");
                              slaying = false;
                            } else {
                              youHit = Math.floor(Math.random() * 2);
                            }
                            } else {
                            console.log("Spider have hit you.");
                            var health = health - 1;
                            var energy = energy - 1;
                            console.log("HEALTH = " + health)
                            console.log("ENERGY = " + health)
                            if (health || energy === 0) {
                                console.log("The end." + "You are dead.")
                            }
                            slaying = false;
                            }
                            }
                            spiderFight = false;
                            }
                        break;
                        case "RUN":
                            console.log("OK you have escaped the spider. Wow I did not expect that.");
                        break;
                        case "SCREAM":
                            console.log("")
                        break;
                        default:
                            console.log("Not sure if that is a choice, try again.");
                        break;
                    }
            break;
            case "DO NOT OPEN":
                console.log("OK no adventure today.");
            break;
            default:
                console.log("Not sure if that is a choice, try again.");
            break;
        }
    break;
    case "DO NOT OPEN":
        console.log("OK no adventure today.");
    break;
    case "SAVE FOR LATER":
        console.log("Yes maybe you should open it with your parents.");
    break;
    default:
        console.log("Not sure if that is a choice, try again.");
    break;
};


#2

Oh I found it ! I dont need your help anymore but thanks.


#3

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