Issue with follow up prompts in my [SWITCH]


#1


https://www.codecademy.com/courses/javascript-beginner-en-ZA2rb/0/5?curriculum_id=506324b3a7dffd00020bf661#


When I answer the prompt for a weapon, it's been giving me the follow up prompt for SWORD regardless of what my answer was.


var answer = prompt("A battle wages outside your barracks. You rush to the armaments and look for a weapon. Do you choose the SWORD, the BOW, or the STAFF?").toUpperCase();
switch(user) {
    case 'SWORD':
        console.log("A mighty blade it is.");
        var strong = prompt("Do you have the strength to weild it? YES or NO?").toUpperCase();
        var trained = prompt("Are you trained in the ways of the blade? YES or NO?").toUpperCase();
        if (strong === "YES" && trained === "YES"){
            console.log("Your strength and prowess will strike fear, and steel, into the hearts of your enemies.");
        }
        else if (strong === "NO" && trained === "YES" || strong          === "YES" && trained === "NO") {
            console.log("Then you'll have to make do with it. Get out there and fight!");
        }
        else {
            console.log("You're failure on the battlefield shall be the subject of much laughter.");
        }
        break;
    case 'BOW':
        console.log("Expertly crafted for deadly accuracy.");
        var agile = prompt("Are you agile? YES or NO?").toUpperCase();
        var eyes = prompt("Do you have sharp eyes? YES or NO?").toUpperCase();
        if (agile === "YES" && eyes === "YES") {
            console.log("With you out there, they won't even be able to run in fear!");    
        }
        else if (agile === "NO" && eyes === "YES" || agile === "YES" && eyes === "NO") {
            console.log("Hopefully one will make up for the other.");
        }
        else {
            console.log("Your allies may have more to fear of you than your enemies.");    
        }
        break;
    case 'STAFF':
        console.log("It is imbued with magical energy.");
        var intellect = prompt("Are you smart enough to weild such power? YES or NO?").toUpperCase();
        var magic = prompt("Have you much skill with the magical arts? YES or NO?").toUpperCase();
        if (intellect === "YES" && magic === "NO") {
            console.log("Then they will not live to rue this day.");
        }
        else if (intellect === "NO" && magic ==="YES" || intellect === "YES" && magic === "NO") {
            console.log("Beware what you will be capable of...");
        }
        else {
            console.log("The best case scenario is that your foolishness only gets yourself killed.");    
        }
        break;
    default:
        console.log("I do not see that weapon here. All I see is the SWORD, the BOW, and the STAFF.")
    };
    
var user = answer;


#2

the result of the prompt is stored in answer, so that is what you should use for switch:

switch(answer)

#3

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