• <!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;
      }

04_ switch 练习 _ 你及格了吗的更多相关文章

  1. 05_ switch 练习 _ 今天星期几

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  2. 面试题04_替换空格_剑指Offer系列

    题目描写叙述 请实现一个函数,将一个字符串中的空格替换成"%20". 比如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy. 解题思路 ...

  3. Struts框架笔记04_拦截器_标签库

    目录 1. Struts2的拦截器 1.1 拦截器概述 1.2 拦截器的实现原理 1.3 Struts的执行流程 1.4 拦截器入门 1.4.1 环境搭建 1.4.2 编写拦截器 1.4.3 配置拦截 ...

  4. Powershell Switch 条件

    Powershell Switch 条件 6 21 1月, 2012  在 Powershell tagged Powershell教程/ 分支/ 字符串/ 数字/ 条件by Mooser Lee 本 ...

  5. PowerShell中的一个switch的例子

    在这个例子中, 应该注意 Switch语句里对数字范围条件的使用 break的使用 字符串的拼接 数组的声明   ) foreach ($element in $array) { switch($el ...

  6. 275 原型与原型链:显式原型prototype ,隐式原型__proto__,隐式原型链,原型链_属性问题,给原型对象添加属性/方法

    1.所有函数都有一个特别的属性 prototype : 显式原型属性 [普通构造函数的实例对象没有prototype 属性,构造函数有__proto__属性,原型对象有__proto__属性 ] 2. ...

  7. 通过百度echarts实现数据图表展示功能

    现在我们在工作中,在开发中都会或多或少的用到图表统计数据显示给用户.通过图表可以很直观的,直接的将数据呈现出来.这里我就介绍说一下利用百度开源的echarts图表技术实现的具体功能. 1.对于不太理解 ...

  8. Html小插件

    1.天气预报插件 效果图: 源代码: <iframe width="650" scrolling="no" height="60" f ...

  9. [翻译] C# 8.0 新特性

    原文: Building C# 8.0 [译注:原文主标题如此,但内容大部分为新特性介绍,所以意译标题为 "C# 8.0 新特性"] C# 的下一个主要版本是 8.0.我们已经为它 ...

随机推荐

  1. Java小知识点总结

    目录 配置 数据库配置文件 基础知识 Switch i++和++i 快捷打代码 输入数据 代码折叠 super关键字 instanceof 防止类型强制转换带来的错误 继承 第一个Java程序 Jav ...

  2. MessageFormat的用法,java动态替换String字符串中的占位符

    import java.text.MessageFormat; import java.util.GregorianCalendar; import java.util.Locale; public ...

  3. A fine property of the convective terms of axisymmetric MHD system, and a regularity criterion in terms of $\om^\tt$

    In [Zhang, Zujin; Yao, Zheng-an. 3D axisymmetric MHD system with regularity in the swirl component o ...

  4. Python 入门基础15 --shutil、shelve、log常用模块2、项目结构

    今日内容: 一.常用模块 2019.04.10 更新 1.time:时间 2.calendar:日历 3.datatime:可以运算的时间 4.sys:系统 5.os:操作系统 6.os.path:系 ...

  5. laravel5.4 向闭合函数内部传递参数

    laravel  向闭合函数内部传入参数

  6. LeetCode第十四题-字符串数组中最长的共同前缀

    Longest Common Prefix 问题简介: 编写一个函数来查找字符串数组中最长的公共前缀字符串,如果没有公共前缀,则返回空字符串"" 举例: 1: 输入: [“xwq” ...

  7. Selenium Locating Elements

    Locating Elements Location Methods: find_element_by_id find_element_by_name find_element_by_xpath fi ...

  8. 一个基于Net 的CMS -- Umbraco CMS

    一个基于Net 的CMS  -- Umbraco CMS:   https://umbraco.com/ Sitecore 和 EPiServer    http://www.bubuko.com/i ...

  9. nginx php-fpm开启session

    一.  权限问题,这个是发生在多数情况下 找到php session目录设置给 nginx 或者 apache最大权限 二.  配置问题按如下就没啥问题了 [Session] session.save ...

  10. Alpha 事后诸葛亮(团队)

    前言 事后诸葛亮?作业名真的不好听,下一届还要沿用吗? 队名:小白吃 通向hjj博客的任意门 思考总结 设想和目标 我们的软件要解决什么问题?是否定义得很清楚?是否对典型用户和典型场景有清晰的描述? ...