Code your own adventure token {


#1

please help me find the mistake! its an unexpected token { response that i am getting.

var user = prompt("You are walking in the forest and see a dinosaur!! What do you do? Run, hide or attack the velocioraptor?").toUpperCase();
switch(user) {
case 'ATTACK':
console.log("Thats a crazy idea!");
var attackOne = prompt("Do you hit it with an axe");
var attackTwo = prompt("Do you then throw a javelin?");
if(attackOne == "yes" && attackTwo == "yes") {
console.log("Wow! You're quite the fighter, good job the raptor is dead!"); } else (attackOne =="no" || AttackTwo == "no") {
console.log("You can't just stand there and expect to live!");
}};

    break;
case 'RUN':
    var run = prompt("Are you fast or slow?").toUppercase();
    
    break;
case 'HIDE':
    var hide = prompt ("Do you hide in a tree or in a cave?").toUppercase();
    
    break;
default:
    console.log("That't not a choice, please choose run, hide or attack.");

};


#2

Your else statement is set up wrong. Else statements don't take a condition.It's what runs if nothing qualifies the if or else if.


#3

thanks! i fixed it!!


#4

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