Code Your Own Adventure 2. Help!


#1

var user = prompt("Are you good?").toUpperCase();
switch(user){
case 'YES':
var ask = prompt("On a scale of 1 through 10, how are you?");
if(ask < 5) {
console.log("Be more happy");
break;
}
else {
var a = prompt("Are you kind of happy?").toUpperCase();
var b = prompt("Are you joyful?").toUpperCase();
if (a === "YES" || b === "YES") {
console.log("Good");
break;
}
else {
console.log("Be happy");
break;
}

case 'NO':
    console.log("Hope you feel better");
    break;
case 'MAYBE':
    console.log("Yes or No, pick one");
    break;
default:
console.log("I didn't catch that, please try again");

}

It says "SyntaxError: Unexpected token case" plz help


#2

Hi @bitslayer84692

I correct your code, I hope you'll see your mistakes and you'll train

var user = prompt("Are you good?").toUpperCase();

switch(user){
case 'YES':
var ask = prompt("On a scale of 1 through 10, how are you?");

if(ask < 5){
console.log("Be more happy");
}else{
var a = prompt("Are you kind of happy?").toUpperCase();
var b = prompt("Are you joyful?").toUpperCase();
};
     
if(a === "YES" || b === "YES"){
console.log("Good");
}else{
console.log("Be happy");
};
break;

case 'NO':
console.log("Hope you feel better");
break;
    
case 'MAYBE':
console.log("Yes or No, pick one");
break;

default:
console.log("I didn't catch that, please try again");
};

Hold on :wink: