34---JS基础-----switch练习

一 代码

练习同样很简单,没必要去看。

1 练习1

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>switch练习1</title>
		<script type="text/javascript">
			/*
			 * 对于成绩大于60分的,输出'合格'。低于60分的,输出'不合格'
			 * 
			 * 6x  /  10 = 6
			 * 7x  /  10 = 7
			 * 8x  /  10 = 8
			 * 9x  /  10 = 9
			 * 100 /  10 = 10
			 * 
			 */
			var score = 75;
			
			/*switch(parseInt(score/10)){
				case 10:
				case 9:
				case 8:
				case 7:
				case 6:
					console.log("合格");
					break;
				default:
					console.log("不合格");
					break;
			}*/
			
			switch(true){
      
      
				case score >= 60:
					console.log("合格");
					break;
				default:
					console.log("不合格");
					break;
			}
			
		</script>
	<body>
	</body>
</html>

2 练习2

略。这个练习没答案,懒得自己写,因为真没必要写出来。

猜你喜欢

转载自blog.csdn.net/weixin_44517656/article/details/121310305