Code Your Own Adventure 2! 5/10 (logical operators) can't find the syntax error


#1


https://www.codecademy.com/courses/javascript-beginner-en-ZA2rb/0/5?curriculum_id=506324b3a7dffd00020bf661#


i keep getting this error "SyntaxError: expected expression, got keyword 'case' " and i can't find the bug.


var user = prompt("What's your name?");
var answer = prompt("You hear a loud creepy scream while you're sleeping. You wake up scared and take the lamp that you have by your bad. You take a look outside your door. You see the BATHROOM, your PARENTS ROOM and the LIVINGROOM. Which path do you take?").toUpperCase();

switch(answer) {
    case 'BATHROOM':
        var KITCHEN = prompt("You open the bathroom door, you see a little bit of blood in the sink. You try to wash it away but instead of watter, blood's comming out the sink, very thik blood. You stop it. You then see blood stains leading to the KITCHEN but at the same time you hear some loud noise comming from DOWN STAIRS. Do you go to the KITCHEN or do you go DOWN STAIRS?")
        if(KITCHEN === 'KITCHEN') {
            console.log("You go to the kitchen by following the blood stains. In the kitchen you see a smal puddle of blood and something written in red on the wall. It says 'You're next'.You get realy creeped out. You touch the written text on the wall to check if it's blood but... it's just ketchup.");
        }
        else if(KITCHEN === 'DOWN STAIRS') {
            console.log("You go down stairs. You see that your dads working space is a chaos. Torn paper, monitor on the floor, the chair is no there, ect. You put the monitor on the desk and run the PC. Unfortunatley you don't know the password.")
        }
        else {
            console.log("You don't go to the KITCHEN and you don't go DOWN STAIRS. Instead you stay in the bathroom. Suddenly the thik blood from the sink attacks you. You die...")
        break;
    case 'PARENTS ROOM':
        console.log("Your parents are not home but there's a note lying on the bed. You read it. 'Hi darling, me and your dad wen hiking for a feew days as we told you yesterday. We'll be back in 3-4 days and since you're 15 years old, i think you can stay by your own. You can invite your friend over but make sure the house stays clean. Much love, Mum.'")
        break;
    case 'LIVINGROOM':
        console.log("You go to the livingroom. You try to switch the light on but it doesn't seem to work so you try to turn on the TV. The TV can't find a signal and flashes white.")
        break;
    default:
    console.log("You don't go anywhere and lock your room. You try to switch the light on but it doesn't work. You need to improvise so you take a few candels and put them in different locations so your room gets brighter.You then try to call someone but there's no signal.")
    break;
}


#2

check again
maybe you just missed a opening ( { ) or closing(}) bracket


#3

Thank for the help rcodeman.

I found that i forgot } after else


#4

you're most welcome :slight_smile:


#5

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