5. Logical Operators


#1

Alright, for the Code Your Own Adeventure 2 - I'm getting a generic "Syntax Error" message. I feel like everything is pretty close to being right though. Any thoughts on where I messed up? Suggestions on how to fix?

var answer = prompt("What would you like me to ask you?").toLowerCase();
var user = answer;

switch(user) {
    case'How was your day?':
        var today = prompt("Do you mean today?").toLowerCase();
        var orNot = prompt("As in this very hour of this very day?").toLowerCase();
        if (today && orNot) {
            console.log("Geez alright, how is your day?");
        }
        else{
            console.log("I could, but I don't really care");
        }
        break;
    case'What is your favorite color?':
        var red = prompt("But what about red?").toLowerCase();
        var green = prompt("Or green??").toLowerCase();
        if (red || green === "yes") {
            console.log("Very clutch");
        }
        else: {
            console.log("But if its not the same as mine, It doesn't count");
        }
        break;
    case"What are you doing?":
        console.log("Not exciting enough for my tastes");
        break;
    default:
        console.log("That's a weird question.");
        break;
};

#2

Hi this Line

var answer = prompt("What would you like me to ask you?").toLowerCase();

Remove The .toLowerCase() because It Will downcase your input But your case has uppercase letter in the string

case'How was your day?':

#3

Good catch, but I'm still receiving the same syntax error message.


#4

then the else statement

else: {
            console.log("But if its not the same as mine, It doesn't count");
        }

you have : just after else


#5

That was it, thanks again. I've got to get used to having a finer eye for detail!


#6

that worked with me
var user = prompt("what would you do if you saw a monster ??");
switch(user) {
case'how was your day?':
var good = prompt("was it good?");
var bad = prompt("was it bad");
if(bad === "yes"&& good === "yes") {
console.log("good!");
} else {
console.log("shut up!");
}
break;
case 'what is your favorite color?':
var red = prompt("is your favorite color is red");
var green = prompt("is your favorite color is red?");
if(green === "yes" || red === "yes"){
console.log("you got a great taste!");
}
break;
default:
console.log("??");
break;
};