Switch goes to default


#1


My code continues to go to default response. I have tried the upper and lower case options, changing all my cases accordingly. Even when removing upper and lower case the issue persists.


var user;
var answer = prompt("Are you ready to join Vox Machina? Let's fight the dragon. How do you fight it? Choose cast a spell, stab, or cutting words.");
switch (user) {
    case 'cast a spell':
        console.log("The dragon is blinded by your magic.");
        break;
        case 'stab':
            console.log("You can't break through dragon hide.");
            break;
            case 'cutting words':
                console.log("You have distracted the dragon.");
                break;
                default:
                console.log("That's not how you fight a dragon.");
}


#2

You stored the user's response in a variable called answer, but then your switch asks for the user variable. Why two variables anyways? :slight_smile:


#3

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