Latest 10. coding an adventure


#1


I am getting an error that is saying unexpected token case. I can't figure out why it is not reading my case. It also says there is a problem with my syntax.


var user = prompt("You are walking down town and you hear screams coming from a ally. Do you go and SEE or do you STAY your course?").toUpperCase();

switch(user) {
case 'SEE':
    var arm = prompt("You see a women trying to get away from ninjas. What are you going to do? Arm yourself?").toUpperCase();
    var call = prompt("Are you going to CALL the police?").toUpperCase();
if (arm === "YES")
    var ready = prompt("Choose your weapon! Do you want a SHEILD and a broad sword? Or do you choose light strong BODY armer and a katana.").toUpperCase(); 
    switch(ready)
    case 'SHEILD'&&'BODY':
        prompt("Do you RUN or FIGHT?").toUpperCase();
        if("RUN"){
            console.log("Wow you really do have a yellow streak down your back.");
        }
        else{
            console.log("You may win this thing after all.");
        }
        break;
        default:
        console.log("That is not a choice here soildier.");
} 
else {
    var police = prompt("Now the police are on the phone are you going to stay and FIGHT for the women or are you going to RUN?")
    if("RUN"){
        console.log("Wow couldn't even stay to try and help.");
    }
    else{
        var fight = prompt("Now choose your weapon! A SHIELD and a broad sword? Or a light weight strong BODY armor and a katana?");
        switch(fight){
            case 'SHIELD'&&'BODY':
                console.log("You are going to save this womans life!");
            break;
            default:
            console.log("That was not an option soildier!");
        }
}
break;
case 'STAY':
    console.log("There was so much more you could have done...");
    break;
default:
    console.log("Ummm that was not a choice...");
break;
}


#2

For those of you who looked at this problem and scratched your head I have figured that I used to many case's and java didn't like the way that I had set it up. This is my updated version that works, take a look if you are having trouble with your own.

var user = prompt("You are walking down town and you hear screams coming from a ally. Do you go and SEE or do you STAY your course?").toUpperCase();

switch(user) {
	
    case 'SEE':
        var arm = prompt("You see a women trying to get away from ninjas. What are you going to do? Arm yourself?").toUpperCase();
        var call = prompt("Are you going to CALL the police?").toUpperCase();
        
        if (arm === "YES"){
            var ready = prompt("Choose your weapon! Do you want a SHEILD and a broad sword? Or do you choose light strong BODY armer and a katana.").toUpperCase(); }

        if (ready==='BODY' || call==='YES'){ 
                console.log("Wow you really do have a yellow streak down your back.");}
        if (ready==='SHIELD' && call==='YES'){
            console.log("No Super Hero you Are you no.");}
        if (ready==='SHIELD' || call==='NO'){
            console.log("You tough guy you. Get Gud.");}
        else {
            console.log("Something Happened.");
            }
                
        break;
        
    default:
        console.log("That is not a choice here soildier.");
}

#3

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