Code your own adventure, Logical Operators


Hey all!

I am having a bit of a challenging run with this exercise. I know I'm missing something in the process but I cant figure it out. I'd appreciate any insight on my work that will help this along. Feeling pretty stuck, particularly with inserting the if/else statements... Thanks in advance!

Here's my code...

var user = prompt("You are passing through a dark alley when two figures approach you. Do you RUN, KEEP WALKING, or ATTACK THEM before they attack you? ").toUpperCase();
var scaredStiff = prompt("Are you feeling bold?" + "yes/no?").toUpperCase();
var weapon = prompt("Did you remember your knife today?" = "Yes/ no?").toUpperCase();

switch(user) {
case 'RUN' :
    if  (scaredStiff === "No" && weapon === "NO"); {
    console.log("You run like the dickens and make it home safely.  That   was close. You live to see another day."); }
   else {
   console.log("you are grabbed by your coat by the one on the left and   you realize it's you're best friend and your girlfriend just messing with  you.");


    if(scaredStiff === yes || weapon === no); {
   console.log("You put some swag in your step and keep struttin' on.                                           Good job. "); }
else {
    console.log("You turn and walk briskly in the opposite direction.  You live on to eat yet another pancake.");


case 'ATTACK  THEM' :
    if(scaredStiff === yes || weapon === yes); {
    console.log("You pull out a knife and start charging wildly. Sadly, you have brought a knife to a gunfight.  You're shot and left for dead. Game Over");


        else { 
        console.log ("They keep walking past you while wondering amongst themselves if you are planning to mug them.");


    console.log("You freeze from fear and wet yourself.  When they get close you realize it's your friend and your date.  Enjoy your cab ride home with them in your soggy drawers u ninny.");


Remove the semicolon ; in this line.
And what @lastshepherd said is correct also.


This is wrong ==> if ( ); { }
Don't use ; after if statement...


Thank you lastshepard, I appreciate you going through my long winded code. I made those changes but I'm still getting an "invalid left hand side in assignment." All good, Ill figure it out soon! Cheers!


Thank you! Made those changes but have not had success yet in pushing it through. I'm getting an "invalid left hand side in assignment" notification, do you know what that means?. Appreciate your time. Cheers!


Could you post your updated code?


Hey, something happened when I closed that tab and I ended up losing my work. I guess I will redo it, It's probably for the best anyway. I could copy and paste it back in from here but I think I need the practice to wrap my head around the exercise better. Thanks for your help!


I felt you need some motivation so i checked your code completely again, There was two other mistakes:

  1. In your "prompt", Use them like this:

var user = prompt("A").toUpperCase();
var scaredStiff = prompt("B").toUpperCase();
var weapon = prompt("C").toUpperCase();

  1. In your "switch",

Wrong ==> if(scaredStiff === yes || weapon === yes)

If they are Uppercase they SHOULD be uppercase with " like this: if(scaredStiff === "YES" || weapon === "YES")

Wish you luck...


Hey, thank you so much! I am just at work but will check all this again when i finish up. Ill let you know how it turns out! cheers