SyntaxERROR: unexpected token )


#1


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


The error message says SyntaxError: unexpected token )


var user = prompt("Walking down the road you see a huge Baby Duck. What do you do RUN away, PAY him or FIGHT","type answer here").toUpperCase();
switch (user){
    case('RUN') :
        var answer1 = prompt("Are you faster than a Baby Duck")
        var answer2 = prompt("Did you get a head start")
        if(answer1 || answer2){
            console.log("You where able to escape the evil Baby Duck")
        } else { 
            console.log("You where to slow and was pecked to death by the Duck")
        }
   break;
    case ('PAY') :
        var ans1 = prompt("Do you have money?")
        var ans2 = prompt("Is it Baby Duck Dollars"?)
        if (ans1 && ans2) {
            console.log ("The duck is happy and has allowed you to pass")
        } else { 
            console.log("The duck gets angry and sits on you")
        }
    break;
    case('FIGHT') :
        var ans3 = prompt("Are you a master in baby duck Kung-fu")
        var ans4 = prompt("Are you Strong")
        if(ans3 || ans4) {
            console.log("WOW! YOu knocked him out with one punch")
        } else{
            console.log("Oh no he's pecked your eyes out")
        }
    break;
    default:
    console.log("Your stupid decision amuses that duck and he eats you")
}


#2

HI this line

var ans2 = prompt("Is it Baby Duck Dollars"?)

you put the ? outside teh string


#3

Cant thank you enough thanks so much


#4

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