Code let's me continue but doesn't bring console logs


#1

The lesson is saying 'way to go', but when I run through the game, none of the logs come back after weapons. Any insight? I don't want to think I know what I'm doing if I'm making mistakes!
Code
var user = prompt("You are in the enemy's castle trying to find the kidnapped Prince. You see an enemy guard coming, what do you do? FIGHT, HIDE, or RETREAT?").toUpperCase();

switch (user){
case 'FIGHT':
var weapon=prompt("You are serious about rescuing the Prince! Do you have a weapon? (YES or NO)").toUpperCase();
if (weapon === "YES") {
var mace=prompt ("do you have a mace?").toUpperCase();
var sword=prompt("do you have a sword?").toUpperCase();
if( mace==="YES" || sword==="YES") {
console.log("Success! You have beaten the guard. Continue on your way")
}else if (mace==="YES" && sword==="YES"){
console.log("Wow! You're really prepared with 2 weapons! You handily subdue the guard. Continue on your way")
} else {
console.log ("while you are brave, the guard has a sword and has beaten you. You need to escape to tend to your wounds.")
}
break;
switch (user){
case 'HIDE':
var hidingSpot=prompt ("Good choice; wait until you see what you are up against. Do you hide behind a TAPESTRY or in an empty NICHE?").toUpperCase();
if (hidingSpot==="TAPESTRY"){
console.log("Good thing you are so thin! You've gone unnoticed and can continue on your quest.")
} else{
console.log("Good choice! You have been mistaken for a statue and can continue on your quest.");
break;
switch (user){
case 'CONTINUE':
var moreGuards=prompt("do you see any more guards coming? (YES or NO)").toUpperCase();
var backup=prompt("Has your backup arrived? (YES or NO)").toUpperCase();

switch (user)
{case 'RETREAT':
    console.log ("Good choice! That guard wasn't alone; you would've been a goner for sure! Retreat to camp and regroup.");
break;
default:
console.log("Sorry! You took too long to decide! The guard has seen you and you have been captured!");
break;
}
}
}}
}

};


#2

Hi @alsoucy

I corrected your code, pay attention about your if, else if and condition closure :

var user = prompt("You are in the enemy's castle trying to find the kidnapped Prince. You see an enemy guard coming, what do you do? FIGHT, HIDE, or RETREAT?").toUpperCase();

switch (user){
    case 'FIGHT':
        var weapon = prompt("You are serious about rescuing the Prince! Do you have a weapon? (YES or NO)").toUpperCase();
        if(weapon === "YES"){
            var mace = prompt("do you have a mace?").toUpperCase();
            var sword = prompt("do you have a sword?").toUpperCase();
                if(mace === "YES" && sword === "YES"){
                    console.log("Wow! You're really prepared with 2 weapons! You handily subdue the guard. Continue on your way");
                }else if(mace === "YES" || sword === "YES"){
                    console.log("Success! You have beaten the guard. Continue on your way");
                }
        }else{
            console.log("while you are brave, the guard has a sword and has beaten you. You need to escape to tend to your wounds.");
        }
    break;
    
    case 'HIDE':
        var hidingSpot = prompt("Good choice; wait until you see what you are up against. Do you hide behind a TAPESTRY or in an empty NICHE?").toUpperCase();
        if(hidingSpot === "TAPESTRY"){
            console.log("Good thing you are so thin! You've gone     unnoticed and can continue on your quest.");
        }else{
            console.log("Good choice! You have been mistaken for a     statue and can continue on your quest.");
        }
    break;
    
    case 'CONTINUE':
        var moreGuards = prompt("do you see any more guards coming? (YES or NO)").toUpperCase();
        var backup = prompt("Has your backup arrived? (YES or NO)").toUpperCase();
        //And here ? There isn't condition about his response, add it

    case 'RETREAT':
        console.log("Good choice! That guard wasn't alone; you would've been a goner for sure! Retreat to camp and regroup.");
    break;

    default:
        console.log("Sorry! You took too long to decide! The guard has seen you and you have been captured!");
}

Hold on :wink:


#3

thank you for taking the time!!