My code is working, but when I put in the answer, it always logs default to the console


#1


Replace this line with your code. 
var user = prompt("The Gorganite wants to fight you, do you FIGHT him, PAY him to leave you alone, or RUN away?").toUpperCase();

switch(user) {
    case 'Fight' || 'Fight Him':
        console.log("You win").toUpperCase();
        break;
    case 'Pay' || 'Pay Him':
        console.log("You can Live").toUpperCase();
        break;
    case 'Run' || 'Run Away':
        console.log("Hurry Run!! Better hopw he doesnt catch you".toUpperCase());
        break;
    default:
        console.log("You died");
}


#2

Invalid case. Will never work written as an expression like this.

You are converting your inputs to uppercase by not testing for all upper in the cases.

log has no attribute toUpperCase.


#3

I have taken away the or symbols and the to uppercase except off the var "user" and it is still not working correctly, but it passes

var user = prompt("The Gorganite wants to fight you, do you FIGHT him, PAY him to leave you alone, or RUN away?").toUpperCase();

switch(user) {
case 'Fight':
console.log("You win");
break;
case 'Pay':
console.log("You can Live");
break;
case 'Run':
console.log("Hurry Run!! Better hopw he doesnt catch you");
break;
default:
console.log("You died");
}


#4

Should be FIGHT so it matches the input. Same applies to the other cases.


#5

Ahhh okay, one more question, I thought that the to uppercase makes it so that it makes the answer all caps? Why did it not work when I just had the first letter of each case capitalized?


#6

    "fight".toUpperCase()   =>  FIGHT

Something to keep in mind is that prompt() returns null when the Cancel button is clicked or the Esc button pressed. null has no attribute, toUpperCase().


#7

thank you so much!! great help!!


#8

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