Problem with syntax - please help


#1


https://www.codecademy.com/courses/javascript-beginner-en-ZA2rb/0/5?curriculum_id=506324b3a7dffd00020bf661


Oops, try again. There was a problem with your syntax.
SyntaxError: Unexpected token {


var dragon = prompt("A Dragon appears. Do you RUN, FIGHT or PAY", "Type your answer: RUN, FIGHT or PAY").toUpperCase();

switch(dragon){
    case "RUN":
        var fast = prompt("Are you fast?", "YES or NO").toUpperCase();
        if (fast === "YES"){
            console.log("Nice! You ran away from the Dragon!");
            }
            else{
                console.log("Oh no! It looks like you're in the dragon's stomache");
                }
        break;
    case "FIGHT":
        var strong = prompt("Are you strong?", "YES or NO").toUpperCase();
        var brave = prompt("Are you brave?", "YES or NO").toUpperCase();
        if(strong === "YES" && brave === "YES"){
            console.log("Congratulations! You defeated the Dragon! You are a true Knight!");
            }
            else{
                console.log("The dragon burns you!");
                }
        break;
    case "PAY":
        var money = prompt("Do you have money?", "YES or NO").toUpperCase();
        var gold = prompt("Do you have gold?", "YES or NO").toUpperCase();
        if(money === "YES" || gold === "YES"){
            console.log("Great! The Dragon left you alone!");
            }
            esle{
                console.log("If you can't pay - you die!");
                }
        break;
    default:
        console.log("Wrong answer! You will die in pain!");
    }


#2

Found the mistake. Typo. Sorry for the post.


#3

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