No ideas 5/6


#1

My story is you are just an ordinary person, walking through a notoriously dangerous bog, when a hydra pops out at you. Read my code for the whole thing. Anyway, it says I'm supposed to use logical operators, but I can't think of any ideas of where to put them.
var user = prompt("You are walking through a notoriously dangerous bog, when OH NO!!! A hydra pops out and wants to eat you! Should you FEED him by giving him a toenail clipping, FIGHT him, RUN away or SWIM away?").toLowerCase();
switch(user) {
case 'feed':
console.log("Oh, no! You irritated the hydra, which devoured you on the spot!");
break;
case 'fight':
console.log("I hope you're good. You pull out a silver sword and slice one of the hydra's heads off. But now two grow back, even more vicious! You go on a head slicing spree, but now you're surrounded by heads. You're toast.");
break;
case 'run':
console.log("The hydra is in hot pursuit and- wait! Hydra's can't go on land, so you get away safely! Hooray!");
break;
case 'swim':
console.log("You begin swimming, but this is thick, swampy bog water. The hydra, who is used to swimming fast in this environment, quickly catches you. You died.");
break;
default:
console.log("Oops, that's not an option. You take too long trying to figure out what else you can do and the hydra bolts you down.");
}


#2

@jrpsychgal
you can try some thing like this.

Edit:

var user = prompt(  "You are walking through a notoriously "+
                    "dangerous bog, when OH NO!!! A hydra pops out and wants to eat you!" +
                    "Should you FEED him by giving him a toenail clipping, "+
                    "FIGHT him, RUN away or SWIM away?").toLowerCase();
switch(user) {
case 'feed':
console.log("Oh, no! You irritated the hydra, which devoured you on the spot!");
break;
case 'fight':
    user = parseInt(prompt("How many weapons do you have"),10);
    if(user < 1){
        console.log("You better run mohito");
    }
    else if(user > 1){
        user = prompt("Do you have a sword? yes or no").toLowerCase();
        if(user.trim().startsWith("y")|| user == "yes"){
                console.log("I hope you're good."+
                "You pull out a silver sword and slice one of the hydra's heads off"+
                ". But now two grow back, even more vicious!"+
                "You go on a head slicing spree, but now you're surrounded by heads"+
                "You're toast.");
        }
            else if(user.trim().startsWith("n")|| user == "no"){
                user = parseInt(prompt("How many pounds can you lift?"),10);
                console.log("Awesome");
                //ask user a question
                //it can go on an on
            }
            else{
                console.log("You are nervous an that was a bad idea you just got woomped");
            }
        
    }
        else{
        console.log("Thas not enough hit the dirt");
        
        }
    break;
    case 'run':
        console.log("The hydra is in hot pursuit and- wait! Hydra's can't go on land, so you get away safely! Hooray!");
        break;
    case 'swim':
        canswim= prompt("Do you know how to swim? yes(y) or no()").toLowerCase();
        fit = prompt("Are you fit enough to swim? yes(y) or no()").toLowerCase();
        if(canswim.trim().startsWith("y")&& fit.trim().startsWith("y")){
            console.log("Pheeww!! looks like all those lessons and excercises paid off");
        }
        else{
        console.log("You begin swimming, but this is thick, swampy bog water."+
                    " The hydra, who is used to swimming fast in this environment,"+ 
                    "quickly catches you. You died.");
        }
        break;
    default:
        console.log("Oops, that's not an option. You take too long trying to figure out what else you can do and the hydra bolts you down.");
}

Click here to go to labs


#3

It works but they said this :expressionless: :expressionless:

Oops, try again. Make sure to use at least one logical 'or' (||)!**


#4

@may101 I made some changes to the original post


#5

Thanks! I'll make a few changes to the text to personalize it, but it's great.


#6

Yeah, she's right. I don't see a &&... And I see two else's in a row. What are they for?


#7

I just realized this now so sorry...


#8

Made an edit to the original post


#9

It's okay, I decided to add some more stuff to the swim and run options. Thanks anyway.