"yes" or "no" only?


#1


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


Hello Folks! My editor marks my code green, but my code only works for the user input "yes" and "no". Other cases I defined all return the default. Why? Is there something wrong with "."s or commas? (The code is based on the old joke that says Bunny is beaten by the Wolf anyway.)


var user = prompt("Hello Bunny, do you have a cigarette?").toLowerCase();
switch(user)
    {
        case'yes':
            console.log("I'll just give you a slap then.");
            break;
        case'no':
            console.log("No? I'll kick you in the butt.");
            break;
        case'Wait...':
            console.log("Wait what? I'll spank you anyway.");
            break;
        case'Go fishing, Wolf!':
            console.log("ROOOOAAAAAARRRRRR!!!");
            break;
        default:
            console.log("GRRRRRRRR!!!");
    }


#2

well, the user input gets converted to lowercase. and Wait (case) doesn't equal wait (userinput)


#3

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