标签:code utf-8 body htm case doctype class head 练习
<!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;
}
标签:code utf-8 body htm case doctype class head 练习
原文地址:https://www.cnblogs.com/tianxiaxuange/p/9676551.html