1
   var comics = prompt("hey do you like comic books? y or n").toUpperCase();
    switch(comics){
       case "do you like comics":
           if(comics === "y" || comics === "yes" || comics === "Yes") {
            prompt("Sweet!");
       }else{
          console.log("ummmm wrong answer");

      break;
    }


   var comics = prompt("so do you like batman or superman??").toUpperCase();
       case "sylk":
        //So You Like Comics
            if(answr === "superman" || answr === "Superman" && answr === "batman" || answr === "Batman");
            console.log("dude thats awesome me too!!");
            break;
         default:
             window.alert("uh can you re-type that??");

}

它从提示直接到默认:,我不明白我什至有break;'s 和东西。

4

1 回答 1

5

你的语法错误

您的代码中没有开关,您需要通过用户选项comics进行切换,然后将案例写在里面switch block

var comics = prompt("so do you like batman or superman??").toLowerCase();
switch(comics){
    case "sylk": 
        //So You Like Comics
        if(answr === "yes" || answr === "Yes" || answr === "y")
            console.log("dude thats awesome me too!!");
        break;
    default:
        window.alert("uh can you re-type that??");

}
于 2013-06-24T03:24:41.447 回答