Not Picking up case instance



I am trying to get this to pick up the input "United Kingdom" and no matter what i do it will just hit the default that i have listed in the code. Oddly enough it will pick up the input "UK" with no issues and start the IF statement but if i actually spell out the country United Kingdom. Does anyone have some insight as to why this is not working? To me it seems that i am doing the same thing as the Switzerland cases so i don't see why it won't work.

var answer = prompt ("What Country?").toUpperCase();
var user = answer;
switch(user) {
    case "Switzerland":
    case "SW":
        console.log("I see that you want to visit the Country of Superiority");
        var swisscity = prompt("How About Geneva?");
        var swisscity2 = prompt("St Moritz?");
        if (swisscity == "Yes" && swisscity2 == "No") {
            console.log("Nice, one of the most Captavating sites in SW");
    else if (swisscity == "No" && swisscity2 == "Yes") {
        console.log("St Mortiz is Beautiful");
    else if (swisscity == "Yes" || swisscity2 == "Yes") {
        console.log("Either or EH? I like you.");
    else {
        console.log("Neither of them? Okay then...");
    case "United Kingdom":
        console.log("To the UK eh? It's always raining");
        var UKC1 = prompt("How about Liverpool?");
        var UKC2 = prompt("No? London then?");
        if (UKC1 == "Yes" && UKC2 =="No") {
            console.log("Wooo Liverpool!");
        else if (UKC1 == "No" && UKC2 == "Yes") {
            console.log("Off to London!");
        else if (UKC1 == "Yes" || UKC2 == "Yes") {
            console.log("Both? UK Smells bad");
        else {
            console.log("I wouldn't want to go there either");
    case 'To die':
        console.log("To die");
    console.log("Learn to english");


If you're setting the responses to your prompt toUpperCase(), then whatever is input to the prompt will be set to UPPERCASE LETTERS. You can either remove the toUpperCase() or change all your cases to UPPERCASE, ex: Switzerland to SWITZERLAND.

You have no code written to execute for the cases 'United Kingdom' or "Switzerland", even if you remove the toUpperCase() from the answer prompt.

As the code stands, the only cases that will execute are 'SW' and 'UK'. You could make the user aware of this by changing your answer prompt question to "What country, SW or UK?".

Similarly, in your prompts for swisscity, swisscity2, UKC1 and UKC2, change the questions to get the user to input 'yes' or 'no'. Otherwise, the user will only trigger the else statements.


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