:syntax error


#1

var user = prompt("Are you afraid of the dark!");
switch(user){
case'Hungry Goblin':
if(answer===No&&Yes){
console.log("I am going to eat you");
}
else(answer==No||Yes){
console.log("Are you afraid now");
}
break;
case'You':
console.log("I hope you like tasting yourself");
console.log("Cause you ain't eating me");
break;
case'Me':
console.log("Silly Goblin");
console.log("I got Night Vision bring it on");
break;
default:
console.log("Goblin Soup? Yuck");
}
var answer =("yes or no").toUpperCase();


#2

The problem here is that you're miss using the && and || operators. To use them correctly you are going to want to use it like this:
answer == "No" && answer == "Yes"
answer == "No" || answer == "Yes"

Also! Let me ask you this, what if the user enters a string like yes, or NO, or some different variation of the parameters you specified?
-Hope this helped


#3

If you're comparing two things in an if statement remember that each comparison must have an operand attached to it.

if (answer == "No" && answer == "Yes") {...}
//this means yes AND No.. I don't understand the logic you put behind this if statement

and

if (answer == "No" || answer == "Yes") {...}
//If EITHER of these conditions is true, do this code.

And I got to this post a little late, didn't see @earrowood6 said almost exactly the same thing, but I'm going to post this comment anyway cause.. #whynot


#4

SyntaxError: missing before statement keep getting this


#5

SyntaxError: missing before statement keep getting this


#6

while I agree that "no and yes" and "no or yes" don't really make sense as conditions, you also shouldn't have a condition at all on an else statement.

if(condition==true){...} else if (condition2==true) {...} else {...}

Notice that if you want to add another condition, you need to use else if

But... I'm actually not following your code at all. You're using a switch for the variable user, created by the prompt "Are you afraid of the dark!" and the possible responses to that question are Hungry Goblin, You, and Me? Also, do you have answer defined as a variable anywhere?


#7

var user = prompt("Are you afraid of the dark!");
switch(user){
case '1':
var answer =(1||2);
if(answer == "No" || answer == "Yes"){
console.log("1","I am going to eat you"));
}
if/else(answer == "No" && answer == "Yes"){
console.log("2","Are you afraid now");
}
break;

    case'2':
 var answer=(3||4);
    console.log("3","I hope you like tasting yourself");
    console.log("4","Cause you ain't eating me");
    break; 

    case'3':
        var answer=(5||6);
    console.log("Silly Goblin");
    console.log("I got Night Vision bring it on");
    break;

    default:                                                            else{
      console.log("Goblin Soup? Yuck");
    }
      break;

}
var answer =("yes or no").toUpperCase();
whats wrong in here now