Complex adventure, please help


#1



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


I am currently going very complex here because i have another project that i have to do and for some reason this code doesn't go through because it says 'unexpected identifier

confirm(" I am ready to play!" );
var user = prompt("you wake up in a Hospital bed and the hospital is eerily quite, what do you do? get up and look around, lock your hospital room door, or sleep").toUpperCase()
switch(user) {
    case'look around':
     console.log("you open the door and you look down the left hallway and that is reasonably lit, while you look to the left and you see that all the lights are broken reducing you vision to barely able to see you hand in front of your face.")
     var question = prompt("which way do you go, right or left?").toUpperCase();
        if( user === right ) {
       console.log(" you stumble over a flash light and it helps light your way. But you begin to hear noises like slight grumble off in the distance , But you ignore them. you keep walking down the hall and you come to a four way intersection.")
    } else { 
        console.log("you go down the left path and hear a faint noise coming from one of the rooms. you go check it out and it turns out to be a nurse on the ground faitly saying 'help me, help me '")
    }
        break;
     case 'lock the door':
        console.log(" you lock the door and sit back in your bed and try and find out whats going on. After a little while, you hear a growing sound of shoes scarping the ground, and the next moment you hear banging  on the door.")
    var user = prompt(" do you open the door or do you choose to try and open the Window?") .toUpperCase();
     if(user === open the Window) {
         console.log( " the Window opens just enough so that you can fit through, you slide down an awning and make it outside.")
     } else { 
         console.log( " you open the door to find a zombie like person there and this thing attacks you right away, and with nothing to defend yourself with, you die.")
     }
     break;
      case'sleep':
         console.log(" you fall in a deep sleep but the things that are in the hospital break open your door and you end up dying in your sleep. how peaceful.")
         break;
         default:
         console.log(" i dont think you picked the right choice, choose either look around , lock the door, or sleep")
    };
    
        
};


#2

Running it in another interpreter gives:

$ xsel -b > brae.js  # paste your code to file
$ node brae.js       # run with nodejs
/tmp/js/brae.js:16
     if(user === open the Window) {
                      ^^^
SyntaxError: Unexpected identifier

#3

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