天天看點

多分支語句排序

<!DOCTYPE html>

<html>

  <head>

    <meta charset="UTF-8" />

    <title>多分支語句</title>

    <style></style>

  </head>

  <body>

    <script>

      // 對60~100分之間的學生進行分類:及格,中,良,優。

      //從大到小排列

      var grades = prompt("請輸入你的成績:");

      if (grades >= 90) {

        alert("優秀");

      } else if (grades >= 80) {

        alert("良");

      } else if (grades >= 70) {

        alert("中");

      } else if (grades >= 60) {

        alert("及格");

      } else {

        alert("差");

      }

    </script>

  </body>

</html>