5. Logical Operators, Help me Please


#1

Help its says "SyntaxError: Unexpected identifier", but I cant find an Error!

var user = prompt("You are walking down a stoney path, then Blamo, a group of Kobolds jump you, what do you do").toLowerCase();

switch(user) {
case 'fight them':
console.log("You swing for the left Kobold, you deal 10 damage!");
break;

    case 'flee':
        console.log("You flee like a coward, then trip over a rock and die.");

       if (!(flee || fight them)) {
           console.log("You will dance");
       }
       else {
           console.log("You will die!");

       break;

    case 'Break into dance':
        console.log("The Kobolds get confused, and starting backing up looking at you weirdly?");

        if (!(flee && Break into dance)) {
            console.log("You will fight them!");
        }
        else {
            console.log("You will die!");

        break;

        default:
        console.log("You get confused, and a Kobold attacks you, you take 4 damage!");

#2

Heres my most recent attempt on solving this.

var strength = prompt("What is your strength, 1-10");
var Dexterity = prompt("What is your Dexterity, 1-10");
var Intelligence = prompt("What is your Intelligence, 1-10");
var Charisma = prompt("What is your Charisma, 1-10");

var user = prompt("You are walking down a stoney path, then Blamo, a group of Kobolds jump you, what do you do").toLowerCase();

switch (user) {
case 'fight them':
console.log("You swing for the left Kobold, you deal 10 damage!");

    if (Strength >= 8 && Intelligence >= 8) {
        console.log("You get critical damage!");
    }
    else {
        console.log("you deal normal damage");
        break;

case 'flee':
    console.log("You flee like a coward, then trip over a rock and die.");

    if (Dexterity >= 9 || Intelligence < 4) {
        console.log("You do backflip away from the Kobolds, but you still trip and             die.");
    }
    else {
        console.log("Nothing happens.");
       break;


case 'Break into dance':
    console.log("The Kobolds get confused, and starting backing up looking at you             weirdly?");
    break;

    default:
    console.log("You get confused, and a Kobold attacks you, you take 4 damage!");

};


#3

i think you forgot } at :

else {
console.log("you deal normal damage");
}
and
else {
console.log("Nothing happens.");
}
break;


#4

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