r/javaScriptStudyGroup • u/Agitated-Platypus-39 • Jun 06 '21
What am I missing?
After much trial and error, mostly just error, this is what I came up with for a simple escape room.
If someone can tell me what I am missing to get this code working, I'd be forever grateful.
const readlineSync = require("readline-sync");
const userName = readlineSync.question("What is your name?");console.log("Hi " + userName + "!");const entrance = readlineSync.question('Shall we start? [Y] or [N] ');if (entrance == "y"){console.log("Awesome! " +userName+ " Let's start!")}else if (entrance == "n"){console.log('Maybe some other time')process.exit()}'You are locked in a room. You have to find the key before you open the door. You put your hand in the hole, YOU DIE!'var choices=['hole', 'key', 'door']index = readlineSync.keyInSelect(choices, 'Which Choice?');playerPlaying = true;while (playerPlaying == true) {isplayerOptions = truewhile(isplayerOptions == true){//while the player is still active{const isPlayerOption1 = readlineSync.question("Are you sure you wanted to ... \n [1] Open the door? \n [2] Put hand in the hole? \n [3] Find key? \n",{limit:["1","2","3"]});switch(isPlayerOption1){case '2':console.log ('You have died 😵!!!...again')isplayerOptions = true;break;case '3':console.log ('You found the key under the rug!');isplayerOptions = false;break;case '1':console.log ('You do not have key 😫, try again');isplayerOptions = true;break;}}}
1
u/decorona Jun 06 '21
What's the error you're getting? I'm on phone so the more info you provide the better I'll be able to help