【js循环语句练习】做个猜数字的小游戏

<!DOCTYPE html>
<html>
    <head lang="en">
	    <meta charset="UTF-8">
	    <title>猜数字的小游戏</title>
	</head>
	<body>
		<script>
			var input=prompt("请输入您猜的数字");//数字介于0~10
			while(input!=5){
				if(input>0 && input<5) {
					alert("猜小了");
				}else if(input>5 && input<=10){
					alert("猜大了");
				}
				input=prompt("请输入您猜的数字");
			}if(input==5){
				alert("猜对了");
			}
   		</script>
	</body>
</html>

猜你喜欢

转载自blog.csdn.net/qq_39799094/article/details/109213105