老师,这样写可以吗?

来源:2-19 编程练习

慕村602346

2019-04-13 13:13:40

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>猜数字的小游戏</title>
</head>

<body>
<script>
var i = prompt("请输入您猜的数字");
while (i != 5) {

if (i >= 1 && i < 5) {
alert("猜小了!");
i = prompt("请输入您猜的数字");
} else if (i > 5 && i <= 10) {
alert("猜大了!");
i = prompt("请输入您猜的数字");
} else {
alert("请输入1到10以内的数字");
i = prompt("请输入您猜的数字");
}
}
alert("猜对了!");
</script>
</body>

</html>


写回答

1回答

好帮手慕码

2019-04-13

同学你好!

经过测试,代码效果是可以的

如果帮助到了你欢迎采纳 祝学习愉快~

0

0 学习 · 40143 问题

查看课程