Trying to have more than one response option


#1

okay so I have this code and it WORKS, but what if the user inputs a different color? Like, my case option is only set to understand "Red", but the user could write "red", or "RED". What do I do then?

My code: 


var color = prompt("What's your favorite primary color?","Type your favorite color here");

switch(color) {
  case 'red', 'Red':
    console.log("Red's a good color!");
    break;
  case 'blue', 'Blue':
    console.log("That's my favorite color, too!");
    break;
  case 'green', 'Green'://Add your case here!
    console.log("Green sounds nice!");
    break;
  case 'yellow', 'Yellow':
    console.log("I like yellow");
    break;
  default:
    console.log("I don't think that's a primary color!");
}


#2

just change

var color = prompt("What's your favorite primary color?","Type your favorite color here");

to

var color = prompt("What's your favorite primary color?","Type your favorite color here").toUpperCase();

Then change all of your cases to the uppercase version, e.g. RED, BLUE, GREEN, YELLOW.


#3

does that make the machine consider all options regardless of upper/lowercase status of ANY letter? (it could rEd or reD)


#4

It changes whatever the response is (rED, rEd,REd) into full caps (RED). That way, whatever they put in, it will always be uppercase and it's easier to check.