Code Your Own Adventure Strange Return


#1

Can someone help me with this code? Everything works perfectly fine, except if I run the code and input ALEX, and plug in the input for my if/else statement, it always returns with 'Hello, Lisa.' at the end, no matter what the output from my if/else statement? How is this happening? I appreciate the help!

var user = prompt("What's your name?").toUpperCase();
switch(user) {
case 'ALEX':
console.log("That's my name too!");
var user1 = prompt("Boy or girl's name?").toUpperCase();
switch(user1) {
case 'GIRL':
var likeName = prompt("Do you like your name?")
var nameFit = prompt("Does it fit you?").toUpperCase();
if (likeName === 'YES' || nameFit === 'YES') {
console.log("Hurray! It's a pretty name.");
} else {
console.log("Aww, that's too bad.");
}
break;
case 'BOY':
console.log("I don't talk to boys.");
break;
default:
console.log("Please answer BOY or GIRL.");
};
case 'LISA':
console.log("Hello, Lisa.");
var user2 = prompt("Is today a good day?").toUpperCase();
switch(user2) {
case 'YES':
var ifSunny = prompt("Are there sunny skies?").toUpperCase();
var warmWeather = prompt ("Is it warm?").toUpperCase();
if (ifSunny === 'YES' && warmWeather === 'YES') {
console.log ("That sounds wonderful!");
} else {
console.log ("Too bad.");
}
};
break;
case 'PAUL':
console.log("No.");
break;
default:
console.log("Who are you?");
};


#2

In case anyone else runs into the same problem, I figured out my own mistake! I did not put a break statement before my next case, and that's why 'Hello, Lisa.' was returning.

var user = prompt("What's your name?").toUpperCase();
switch(user) {
case 'ALEX':
console.log("That's my name too!");
var user1 = prompt("Boy or girl's name?").toUpperCase();
switch(user1) {
case 'GIRL':
var likeName = prompt("Do you like your name?")
var nameFit = prompt("Does it fit you?").toUpperCase();
if (likeName === 'YES' || nameFit === 'YES') {
console.log("Hurray! It's a pretty name.");
} else {
console.log("Aww, that's too bad.");
}
break;
case 'BOY':
console.log("I don't talk to boys.");
break;
default:
console.log("Please answer BOY or GIRL.");
}
break;
case 'LISA':
console.log("Hello, Lisa.");
var user2 = prompt("Is today a good day?").toUpperCase();
switch(user2) {
case 'YES':
var ifSunny = prompt("Are there sunny skies?").toUpperCase();
var warmWeather = prompt ("Is it warm?").toUpperCase();
if (ifSunny === 'YES' && warmWeather === 'YES') {
console.log ("That sounds wonderful!");
} else {
console.log ("Too bad.");
}
};
break;
case 'PAUL':
console.log("No.");
break;
default:
console.log("Who are you?");
};