5 logical operators


#1

<
I need help on this please? SyntaxError: Unexpected token else

var user = prompt( "which weapon do you prefer!").toUpperCase();
var weapon = prompt("Are well prepared? (yes) or (no)?").tolowerCase();
switch (user) {
** case " Gun":**
** if (weapon === "yes"&& "no")**
** {**
** console.log("charger up");**
** }**
** else if (weapon==="yes"|| "no");**
** {**
** console.log(" ready to war");**
** }**
** else {**


** console.log("KK50 ready");**
** }**
break;
case" knife":
** if (weapon==="yes"&& "no")**
** {**
** console.log("use the color you want");**
** }**
** else if (weapon==="yes"|| "no");**
** {**
** console.log(let's go baby");**
** }**


** break;**
** case" baseball bar":**
** if (weapon==="yes"&&"no" ) {**


** console.log("hold it hard");**
** }**
** else if (weapon ==="yes"||"no") **


** console.log("swing twice");**
** }**
** else { **
** console.log( "let's do the aventure");**
** }**


** break;**
** default:**
** console.log("i have no clue what it is")**
};

`


#2

Why do you have all of these ** signs?


#3

@kalebmfratello just ignore it ? it comes up like that.i wrongly copy and paste it


#4

i change it for the good format.
var user = prompt( "which weapon do you prefer!").toUpperCase();
var weapon = prompt("Are well prepared? (yes) or (no)?").tolowerCase();
switch (user) {
case " Gun":
if (weapon === "yes"&& "no")
{
console.log("charger up");
}
else if (weapon==="yes"|| "no");
{
console.log(" ready to war");
}
else {

        console.log("KK50 ready");
    }

break;
case" knife":
if (weapon==="yes"&& "no")
{
console.log("use the color you want");
}
else if (weapon==="yes"|| "no");
{
console.log(let's go baby");
}

break;
 case" baseball bar":
     if (weapon==="yes"&&"no" ) {

         console.log("hold it hard");
     }
     else if (weapon ==="yes"||"no") {

         console.log("swing twice");
     }
     else { 
         console.log( "let's do the aventure");
     }

break;
default:
console.log("i have no clue what it is")
};


#5

well if your error says that the unexpected piece of code is an else statement then try deleting the else statement and then run the code


#6

@kalebmfratello well i try to remove the else if because i`s kinda messy and i forgot to put a string on [console.log(let's go baby");] like that
var user = prompt( "which weapon do you prefer!").toUpperCase();
var weapon = prompt("Are well prepared?").toLowerCase();
switch (user) {
case " Gun":
if (weapon === "yes"&& "no")
{
console.log("charger up");
}

    else {

        console.log("KK50 ready");
    }

break;
case" knife":
if (weapon==="yes"|| "no")
{
console.log("use the color you want");
}
else {

        console.log("let's go baby");
    }

break;
 case "baseball bar":
     if (weapon==="yes"&&"no" ) {

         console.log("hold it hard");
     }
     else {

         console.log("swing twice");
     }

break;
default:
console.log("I have no clue what it is")
};


#7

so is it working for you now or is there a new error message?


#8

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