5. logical operators - ERROR


#1

I have checked my code and everything seems alright but when I press submit it lays Illegal break!
please help

here is my code

–––––––––––––––––––––––––––––

var user = prompt("You are being chased by a zombie and got cornerd! Do you FIGHT him, PAY him, or RUN?").toUpperCase();

switch(user){
case 'FIGHT':
var Strong = prompt("Are you strong?","Yes or No?").toUpperCase();
var Smart = prompt("Are you smart?","Yes or No?").toUpperCase();

if(Strong || smart) {
        console.log("You found a wooden bat and you beat up the zombie and you sived to see another day! you needed to be smart or strong to do it!");
    }else{
        console.log("You couldnt do anything, the zombie ate your brain");
    }

break;

case 'PAY':
var Money = prompt("Do you have money?","Yes or No?").toUpperCase();
var Amount = prompt("How much do you have?","Amount?")

if(Money === "YES") {
    if(Amount > 5){
        console.log("You bribed the zombie with " + Amount + " and you both live happily ever after!");
    }else{
        console.log("You couldnt bribe him with " + Amount + ", so the zombie ate your brain!");
    }
}else{
    console.log("Too bad, the zombie ate your brain");
}

}

 break;

case 'RUN':
("You were cornered so you couldn't run! The zombie ate your brain because of un-smart decision")
break;
default:
console.log("That's not a option! The zombie ate your brain!")
}


#2

Hey @digitalcoder19693 can you please format your code like this and Ill figure out the problem soon


#3

Thanks for letting me know here is my code
–––––––––––––––––––––––––––––––––––––

var user = prompt("You are being chased by a zombie and got cornerd! Do you FIGHT him, PAY him, or RUN?").toUpperCase();

switch (user) {
    case 'FIGHT':
        var Strong = prompt("Are you strong?", "Yes or No?").toUpperCase();
        var Smart = prompt("Are you smart?", "Yes or No?").toUpperCase();

        if (Strong || smart) {
            console.log("You found a wooden bat and you beat up the zombie and you sived to see another day! you needed to be smart or strong to do it!");
        } else {
            console.log("You couldnt do anything, the zombie ate your brain");
        }
        break;

    case 'PAY':
        var Money = prompt("Do you have money?", "Yes or No?").toUpperCase();
        var Amount = prompt("How much do you have?", "Amount?")

        if (Money === "YES") {
            if (Amount > 5) {
                console.log("You bribed the zombie with " + Amount + " and you both live happily ever after!");
            } else {
                console.log("You couldnt bribe him with " + Amount + ", so the zombie ate your brain!");
            }
        } else {
            console.log("Too bad, the zombie ate your brain");
        }
}

break;

case 'RUN':
    ("You were cornered so you couldn't run! The zombie ate your brain because of un-smart decision")
    break;
default:
    console.log("That's not a option! The zombie ate your brain!")
    }

I hope this helps!


#4

Hey @digitalcoder19693 The syntax error on your code is that you accidently closed your switch statement too soon Here(I will point to the specfic bracket

)

Hope this helped!


#5

Thanks, that helped a lot! Thankyou :slightly_smiling: