Don't know where I am going wrong. Please help


#1


var speed;
var smart;
var strong;
var user= prompt("You see a troll. Do you 'fight' or 'run away' ?").toLowerCase();
switch(user){
    case "fight":
        strong= prompt("Are you strong?");
        smart= prompt("Are you smart?");        }
        if(strong=== "yes" || smart=== "yes"){
            console.log("You beat the troll ");
        }
        else{
            console.log("The troll killed you");
        }
        break;
    case "run away":
        speed= prompt("Are you fast?")
        if(speed=== "yes"){
            console.log("You outran the troll!");
        }
        else{
            console.log("The troll caught and killed you.");
        }
        break;
    default:
    console.log("I didn't get you man");
}.


#2

smart= prompt("Are you smart?");        } // remove }

#3

Why? What is wrong with that statement


#4

Look to your case:

case "fight":
        strong= prompt("Are you strong?");
        smart= prompt("Are you smart?");        } 
        if(strong=== "yes" || smart=== "yes"){
            console.log("You beat the troll ");
        }
        else{
            console.log("The troll killed you");
        }
        break;

The line smart= prompt("Are you smart?"); } is not correct because you put } at the end.


#5

Thanks a lot man. I will always be thankful to you


#6

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