SyntaxError: Unexpected token case


#1



SyntaxError: Unexpected token case

Help?

var user = prompt("What do you want your character to be called?").toLowerCase();
switch (user) {
    case "mei":
        alert("Hello, Mei!");
        var china = prompt("Is your character from China?").toLowerCase();
         if (china === "yes") {
            china = true;
        }
        else{
            china = false;
        }
        var female = prompt("Is your character a girl?").toLowerCase();
         if (female === "yes") {
            female = true;
        }
        else{
            female = false;
        }
        if ( china && female ){
            alert("Nihao, Miss Mei!");
        }
        else {
            alert("Welcome!");
        }
        break;
    case "meg":
        alert("Hello, Meg!");
        var nickname = prompt("Is your character's full name Megan?").toLowerCase(); 
        if (nickname === "yes") {
            nickname = true;
        }
        else{
            nickname = false;
        }
        var besties = prompt("My name is Megan too! Are we besties now?").toLowerCase();
         if (besties === "yes") {
            besties = true;
        }
        else{
            besties = false;
        }
        if ( nickname || besties ){
            alert("Welcome!");
        }
        else{
            alert("There is still so much to learn about this character!");
        break;
    case "dude":
        alert("What's up, dude!")
        var cool = prompt("Are you cool enough to play?").toLowerCase();
        if (cool === "yes"){
            alert("Right on!");
        }
        else {
            alert("Too bad!");
        }
        break;
    default:
        alert("That is not an option. Try Mei, Meg, or Dude.");
}


#2

ou didn't close your else with a curly brace before your break statement.


#3

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