Adding IF/Else to Swich Staement


#1



https://www.codecademy.com/courses/javascript-beginner-en-ZA2rb/0/5?curriculum_id=506324b3a7dffd00020bf661#


I'm getting an unexpected token error.


var user = prompt("Do you have money?").toUpperCase();

switch(user){
    case 'YES':
        console.log("Can I have some?");
        break;
    case 'NO':
        console.log("I don't believe you.");
        if(case === 'YES' && case === 'NO'){
            console.log("Well...which is it?");
        }
        else if(case === "YES" || case === "MAYBE"){
            console.log("I think you mean Yes.");
        }
        else{
            console.log("Whatever, this is a stick up.");
        }
        
    case 'MAYBE':
        console.log("Give me your money.");
        break;
    default:
        console.log("I asked you a question.");
        break;
    
}


#2

using case inside a if or else if statement is a bad idea. I would compare with the user variable:

user === "YES"

since use holds the string with what the entered, not case.


#3

The assignment is to put an if/else into the case. I can't advance to the next lesson.


#4

Oh I see....you can use any conditional in that if/else? You don't have to use the case?


#5

yea, you put the if/if else/else statement inside of the case, but then inside your if statement (in the condition) you shouldn't use case, you should use user, which is the variable that holds what the user entered