JS switch语句

来源:互联网 发布:淘宝智能客服机器人 编辑:程序博客网 时间:2024/05/20 00:12
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title></title>    <script type="text/javascript">
    var a=parseInt(prompt('第一个整数'));    var b=prompt('要进行的运算');    var c=parseInt(prompt('第二个整数'));
switch (b){    case '+':alert(a+b+c+'='+(a+c));break;    case '-':alert(a+b+c+'='+(a-c));break;    case '*':alert(a+b+c+'='+(a*c));break;    case '/':        if(c!=0)        alert(a+b+c+'='+(a/c));        else alert('cuowu,')        break;    default :alert('输入错误!');}
var y = parseInt(prompt('shuru'));        switch (y){            case 1:            case 2:            case 3:alert('yi');break;            case 4:            case 5:            case 6:alert('er');break;            case 7:            case 8:            case 9:alert('san');break;            case 10:            case 11:            case 12:alert('si');break;            default: alert('no');        }
  </script></head><body></body></html>