5 logical operators expected expresion got default


#1

What is wrong with this?

var user = prompt("Your walking through a dark forest and you see the outlines of a figure, do you TALK, RUN , or FIGHT?").toUpperCase();
switch(user) {
case 'TALK':
var clever = prompt("Are you clever?").toUpperCase();
var stealthy = prompt("Are you stealthy?").toUpperCase();
if (clever === 'yes' || stealthy === 'yes'){
console.log("You ask the shadowy figure if it is lost. It answers you but you cannot understand what it is saying so you walk closer to it. As you get closer a shaft of moonlight illuminates it's eyes and you notice that they are completely black. It lets out a demonic howl and charges at you.")
}else{
console.log("The figure grabs you and drains you of all your blood before you can ask who he is.");
}
break;
case 'FIGHT':
var strong = prompt("Are you strong?").toUpperCase();
var nimble = prompt("Are you nimble?").toUpperCase();
if (strong === 'yes' && nimble === 'yes'){
console.log("You strike at the shodowy figure but just as your fist makes contact, it disperses into a cloud of smoke and reappears behind you, but you step to the side as the figure grabs for you.As it rushes past you a shaft of moonlight illuminates the form and you notice that it is a man. You look forward and see the figure of a woman rushing toward him. She has a wooden spike in her hand and when the to figures meet the spike thrusts into the mans chest and he falls to the ground in a pile of dust.")
}else{
console.log("You strike at the shadowy figure but just as you fist makes contact, it disperses into a cloud of smoke, reapearing behind you. It grabs you and sinks it's teeth into your neck, draining you of all your blood");
}
break;
case 'RUN':
var fast = prompt("Are you fast").toUpperCase();
if (fast === 'yes'){
console.log("You do not think twice before you start running in the oposite direction, as you are running you bump into a woman who despite her small size is as sturdy as a brick wall, as you look up you vaguely make out what looks like a wooden spike in here hand, just as she is about to plunge it into your heart you scream 'NO'");
}else{
console.log("You run as fast as you can, but the figure materializes in front of you, halting, you notice a single shaft of moonlight illuminating his eyes which are demonic and black, this is the last thing you see. The demon is behind you know draining your body of blood through your neck")
break;
default:
console.log("That is not an option!");
}


#2

because you are using .toUpperCase(),

the value of your variable will be uppercase so you need to change your if statment condition to
if (clever === 'YES' || stealthy === 'YES'), for example.
Don t forget to change it in all the other if (condition)
other than that your code is correct ^^


#3

Thank you for helping me!


#4

n/p :wink:              


#5

I changed it and I am still getting the same syntax error. I don't understand what exactly "expected expression got keyword" means.


#6

So I found out is because I forgot the close my last else case. HAHAHAHA seriously all the frustration I felt earlier feels ridiculous now.


#7

dont worry we have all been through that once ^^'