5/6 Logical Operators


#1

Add some if/else statements to your cases that check to see whether one condition and another condition are true, as well as whether one condition or another condition are true. Use && and || at least one time each.

var user = prompt("What is your favorite color?").toUpperCase();

switch(user) {
case 'red':
if(red && blue = true) {
console.log "The 4th of July colors"
}
else {
console.log "These are other colors that have nothing to do with the 4th of July, unless it is white."
}
console.log("You like the color of strawberries.");
break;
case 'blue':
console.log("You like the color of the sky.");
break;
case 'pink':
if(pink || red = true) {
console.log "Those are Valentine Day colors."
}
else {
console.log "These colors have nothing to do with Valentine's Day."
}
console.log("You like the a girly color.");
break;
default:
console.log("You like other colors of the rainbow.");
};

ReferenceError: Invalid left-hand side in assignment

What is wrong with my code?


#2

Well, I just want to say this:

This is a function that changes the answer into upper case. Which means:

Probably should turn those capitalized. Also:

To make these work:

You should probably make another prompt to make it work.


#3

What should the extra prompt look like or include?


#4

Something like:

var redBlue = prompt("Do you like RED and BLUE?").toUpperCase();
if(redBlue === 'YES'){}
else{}

var pinkRed = prompt("Do you like PINK or RED?").toUpperCase();
if(pinkRed === 'PINK'){}
else if(pinkRed === 'RED'){}
else{}