Logical Operations Help


#1

Hey my code passed but it only uses my default answer. I'm curious what im doing wrong to not allow my other answers to come through.


var user = prompt("You are walking down the street, a man throws you a gun and a ski mask. He wants you to help him rob a bank. Do you join him? Yes, No or Call Spiderman").toUpperCase();
 switch(user) {
     case 'Yes':
         var robbed = prompt("Have you ever robbed before? (Yes or No)").toUpperCase();
         var intimidating = prompt("Are you an intimidating person?( Yes or No)").toUpperCase();
         if(robbed === Yes && intimidating === Yes) {
             console.log("You just robbed the the biggest bank in New York. You're rich!"); 
             } else {
                 console.log("Enjoy your time in jail. Your new bunk buddy looks friendly");
             };
         break;
     case 'No':
         var run = prompt("Are you a fast runner? (Yes or No)").toUpperCase();
         var fight = prompt("Can you fight? (Yes or No)").toUpperCase();
         if(run === Yes || fight === Yes) {
         console.log("Wow! You are a good samaritan.");
         } else {
             console.log("Oh no! He pistol whipped you and now you are in the hospital.");
         };
         break;
     case 'Call Spiderman':
         var call = prompt("Do you have Spiderman's number? (Yes or No)").toUpperCase();
         var see = prompt("Can you see Spiderman in the area? (Yes or No)").toUpperCase();
         if(call === Yes || see === Yes) {
         console.log("Spiderman is on his way to save the day!");
         } else {
             console.log("Good job, you let the robber get away...");
         };
         break;
     default:
         console.log("The robber doesnt not speak Spanish.")
 }


#2

Your yes's needs to be strings and in all caps (since you used .toUpperCase();) in your conditions.
For example:

if(robbed === "YES" && intimidating === "YES") {
    // random action
};

// instead of
if(robbed === Yes && intimidating === Yes) {
    // random action
};

Check all your conditions.

ALSO, your cases needs to be in all caps too because you used .toUpperCase(); in all your prompts.
eg

case 'YES':
// instead of
case 'Yes':

#3

Cool. Thank you very much!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.