zoukankan      html  css  js  c++  java
  • 04_ switch 练习 _ 你及格了吗

    • <!DOCTYPE html>
      <html>
          <head>
              <meta charset="utf-8" />
              <title>Did u made it ?</title>
          </head>
          <body>
              <script type="text/javascript">
                  var score = +prompt("请输入你的成绩:");
                  if(score >= 0 && score <= 100)
                  {
                      switch(score >= 60)
                      {
                          case true:
                              alert("恭喜你,及格了!" + score + "");
                              document.write("恭喜你,及格了!" + score + "");
                              break;
                          case false:
                              alert("很遗憾,不及格。" + score + "");
                              document.write("很遗憾,不及格。" + score + "");
                              break;
                      }
                  }
                  else
                  {
                      alert("请输入合法分数!");
                      document.write("请输入合法分数!");
                  }
              </script>
          </body>
      </html>
    • 老师的写法:
      •     switch(parseInt(score/10))
            {
                case 10:
                case 9:
                case 8:
                case 7:
                case 6:
                    alert("恭喜你,及格了!" + score + " 分");
                    document.write("恭喜你,及格了!" + score + " 分");
                    break;
                default:
                    alert("很遗憾,不及格。" + score + " 分");
                    document.write("很遗憾,不及格。" + score + " 分");
                    break;
            }
        
            switch(true)
            {
                case score >= 60:
                    alert("恭喜你,及格了!" + score + " 分");
                    document.write("恭喜你,及格了!" + score + " 分");
                    break;
                default:
                    alert("很遗憾,不及格。" + score + " 分");
                    document.write("很遗憾,不及格。" + score + " 分");
                    break;
            }
    --------小尾巴 ________一个人欣赏-最后一朵颜色的消逝-忠诚于我的是·一颗叫做野的心.决不受人奴役.怒火中生的那一刻·终将结束...
  • 相关阅读:
    js设计模式 -- 装饰模式
    前端项目开发(持续补充中)
    URL地址解析
    line-height有无单位区别
    HTTP请求Response Headers
    HTTP请求Request headers
    docker快速入门
    关于layui动态生成文件上传按钮后点击无效的解决办法
    未证实的一个BUG
    实现一个简单的概率发奖问题
  • 原文地址:https://www.cnblogs.com/tianxiaxuange/p/9676551.html
Copyright © 2011-2022 走看看