Im having trouble with 5/6


#1

It says "Oops, try again. It looks like you didn't put in any if/else statements! (Make sure to use if/else, and not the ternary operator '? :'."
And my code is
var user = prompt("Where were you born in USA?").toLowerCase();
switch(user) {
case 'yes':
var answer= prompt("Were you born in Georgia?");
if(answer=='yes'){
answer= true;
var choice= false;
console.log("Sweet I was born in Georgia too.")
if (answer== true && choice == false){
var deal= prompt("Do you like the USA?").toLowerCase();
if (deal=='yes'){
deal= true;
}
if(deal==true|| answer==false){
console.log("The USA looks right for you.")
}
}
}
if(answer=="no"){
asnwer= false;
console.log("LEAVE!!!!")
}
break;
case 'colorado':
console.log("fye lmao");

    break;
case 'hawaii':
    console.log("thats so far bro bro");

    break;
default:
    console.log("mane wtf is that Get outta here!!!");

}

I feel like my code is very messy and not well organized i would love it if someone can help me out and give me a few pointers. Thank you!!!


#2

Yea hey @corerockstar51358! First off please organize your code by selecting over your code and hitting CTRL + K. Secondly your problem is that it clearly states to use the if and else statement. You used the switch statement as said below so fix that and you should be good! Sorry couldnt organize code! Ahh


Noticing a couple problems in Codecademy!
#3

I've seen the suggestion of choosing code and selecting ctrl k. What magic is that supposed to do, please?


#4

Using ctrl+k allows you to keep the format of your text. If you don't use ctrl+k the code will lose its formation and thus it's difficult to read.

Btw i recommend using jsbeautifier.org/. You only have to paste your code there and it will format the code for you. Then you can easily copy it to this forum and use ctrl+k on your code to save the format in your forum post.

var user = prompt("Where were you born in USA?").toLowerCase();
switch (user) {
    case 'yes':
        var answer = prompt("Were you born in Georgia?");
        if (answer == 'yes') {
            answer = true;
            var choice = false;
            console.log("Sweet I was born in Georgia too.")
            if (answer == true && choice == false) {
                var deal = prompt("Do you like the USA?").toLowerCase();
                if (deal == 'yes') {
                    deal = true;
                }
                if (deal == true || answer == false) {
                    console.log("The USA looks right for you.")
                }
            }
        }
        if (answer == "no") {
            asnwer = false;
            console.log("LEAVE!!!!")
        }
        break;
    case 'colorado':
        console.log("fye lmao");

        break;
    case 'hawaii':
        console.log("thats so far bro bro");

        break;
    default:
        console.log("mane wtf is that Get outta here!!!");

}

#5

Im still confused. Like it says i have to use an if else and i am!!!!!!!!!!!!!!!!!!!!! :((((((


#6

@corerockstar51358
In your original code you used no else statements only if's.