<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <script> var num=prompt("輸入0-100的分數"); switch (true){ case num<60: document.write("不合格"); break; case num<70: document.write("一般"); break; case num<90: document.write("良好"); break; case num<100: document.write("優秀"); break; default:document.write("輸入正確的分數") } </script> </body> </html>
switch語句的使用
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.