Need help with if/else statement in case it's confusing


var user = prompt("Hello Welcome To Earth, Prepare To Die. What are you gonna do yes to fight or Pay IN BLLOODD!!!").toUpperCase();
switch(user) {
case 'FIGHT':
if (user && "FIGHT" == "Fight" || "fight")

    console.log("Well, Well, Well. Whack! He Dead!");
case 'PAY': 
    console.log("You Do Know Your Gonna Die Anyway Right But Whatever. Bang!!!!!");
case 'NOTHING': 
    console.log("You KIlled Flowie With DEtermination!");
console.log("Fine Get out of my Way Idiot");



So how switch works:

The switch expression is evaluated once. In your case it is var user.
The value of the expression is compared with the values of each case. In your case it are 'FIGHT', 'PAY', 'NOTHING'.
If there is a match, the associated block of code is executed.

So you have double check for var user. But you don't need it because case does this work. Also you used .toUpperCase(). So var user has capitalized letters.


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