5. Logical Operators - Unexpected token


#1

I'm having a similar issue. "SyntaxError: Unexpected token else" in Code Your Own Adventure 2: Logical operators (part 5).
I tried to reach a bit on this. I want the program to determine if the user is ready and then if so, ask their gender using a Likert scale and respond based on that. Later on, it would complete the rest of the setup - asking name, profession, etc. Trying to get the very barebones of a text-adventure game.
I don't have a ' ; ' after my IF statement. I'm thinking something is going sideways in the order/placement of my IF statement. Can anyone steer me right on this?

var gender = false;
var user = prompt('Are you ready to start your adventure?').toLowerCase();
switch (user) {
    case 'yes':
        console.log('Very well then, let us begin. . .');
        var ready = true;
        break;
    case 'no':
        console.log('Come back when you are ready.');
        var ready = false;
        break;
    default:
        console.log('Answer the question with "yes" or "no".');
        break;
}
if (ready) { /*setting this to ready=true or just ready doesn't matter*/
    console.log('Please use the scale below to choose the answer for the question:');
    console.log('Feminine<|1--2--3--4--5|>Masculine OR "None"');
    var gender = prompt('What is your gender identity for this game? Please pick a number on the line above.').toLowerCase();
    switch (gender) {
        case '1':
            console.log('Okay, Miss, what is your name?');
            gender = true;
            break;
        case '2':
            console.log('Okay, what is your name?');
            gender = true;
            break;
        case '3':
            console.log('Okay, what is your name?');
            gender = true;
            break;
        case '4':
            console.log('Okay, what is your name?');
            gender = true;
            break;
        case '5':
            console.log('Okay, Mister, what is your name?');
            gender = true;
            break;
        case 'none':
            console.log('Okay, what is your name?');
            gender = true;
            break;
        default:
            console.log('Gender is complicated. I trust you to know yourself.');
            gender = true;
            break;
    } 
    else {
        console.log('Come back later.');
    }
    if (ready && gender) {
        console.log('Let us begin!');
    }
    else {
        console.log('Do not mind the newbie effort, please.');
    }

5. Logical Operators - SyntaxError: Unexpected token else
#2

Hi you didn't closed the first if statement


#4

Thank you! I was forgetting a final "}". Now I need only add my || statement and I'm good. Glad to know that I was on the right track :slight_smile: