Does not prompt my 'case'. Automatcally to 'default'


#1

hey guys! I thought I followed the criteria correctly, but maybe I got it entirely wrong. Can you please help me understand why its not allowing me to prompt any of the 'case' choices I created? It automatically does not understand any of the case's whether its upper or lower case. Thanks in advance!

var user = prompt("What would you like to do today?").toUpperCase();

switch(user){
case 'Beach':
var swimming = prompt("Did you bring your swimsuit?").toUpperCase();
var layout = prompt("Did you bring a towel to lay out on?").toUpperCase();
if( swimming && layout === YES){
console.log("It's 100 degrees out and perfect weather!");
} else {
console.log("There's always another day!");
}
break;
case 'Sky Diving':
var indoor = prompt("Are you scared of the heights?").toUpperCase();
var outdoor = prompt("Can we go by the beach?").toUpperCase();
if (indoor === yes || outdoor === yes) {
console.log("You are going to absolutely love it!");
}else {
console.log("It's ok to be scared of heights.");
}
break;
case 'Picnic in the park':
var lunch = prompt("Would you like cheese and crackers?").toUpperCase();
var drinks = prompt("Would you like some wine?").toUpperCase();
if( lunch === yes || drinks === yes){
console.log("I'll prepare the picnic basket right away!");
}else {
console.log("Lets just pick something up on the way.");
}
break;
case 'Snowboarding':
var bus = prompt("Should we get passes to the shuttle bus?").toUpperCase();
var rental = prompt("Should we get a rental?").toUpperCase();
if( bus === yes || rental === yes) {
console.log("Let me make a reservation.");
}else{
console.log("We can find other means to getting there.");
}
break;
default:
console.log("I'm not sure I understand. Can you please elaborate?");
}


#2

I figured out what the error was. I didn't realize that CAPITOLIZING your cases would make such a big difference. thanks!!


#3

Alright. Firstly..

If your going to make the anser to the prompt .toUppercase(); you will need to make your cases in all uppercase as well.. this is why I would actually use .toLowerCase();

Like so:

var user = prompt("What would you like to do today?").toLowerCase();

switch(user){
case 'beach':
var swimming = prompt("Did you bring your swimsuit?").toUpperCase();
var layout = prompt("Did you bring a towel to lay out on?").toUpperCase();

ect...

Now, your program still wouldn't work because of this..

this is what you would need to do

var swimming = prompt("Did you bring your swimsuit?").toLowerCase();
        var layout = prompt("Did you bring a towel to lay out on?").toLowerCase();
            if( swimming === "yes" && layout === "yes"){
                console.log("It's 100 degrees out and perfect weather!");
            } else {
                console.log("There's always another day!");
            }

you did not put quotes around your yes's if( swimming === "yes" && layout === "yes") fixes that.

Note

You can use toUpperCase(). Just remember that your cases have to all be in uppercase then and in quotes.

As long as you fix all these things throughout your code you should be fine :slightly_smiling: .

I realized that you figured out the first part, but figured I would help you out with the second error you would probably get.


#4

Wow, thank you so much for taking the time to respond!!

Ah indeed, quotes around "yes"!! -THANKS!

Thanks for clarifying .toUpperCase and .toLowerCase, that makes much more sense now.

:slightly_smiling: happy coding!