这个作业属于哪个课程 https://edu.cnblogs.com/campus/sdscfz/SF4
这个作业要求在哪里 https://edu.cnblogs.com/campus/sdscfz/SF4/homework/12964
这个作业的目标 第十二次作业
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>猜数字随机数1-10</title>
    <script>
        function getRandom(min, max) {
            return Math.floor(Math.random() * (max - min + 1)) + min;
        }
        var num = getRandom(1, 10);
        var postnum = prompt('猜数字,1-10');
        while (postnum != num) {
            if (postnum > num) {
                alert('大了');
                var postnum = prompt('猜数字,1-10');
            } else {
                alert('小了')
                var postnum = prompt('猜数字,1-10');
            }
        }
        document.write('恭喜您,猜对了');
    </script>
</head>

<body>

</body>

</html>


posted on 2023-05-27 15:30  饭来大碗  阅读(4)  评论(0编辑  收藏  举报