第12次作业

这个作业属于哪个课程 https://edu.cnblogs.com/campus/sdscfz/SF3/
这个作业要求在哪里 https://edu.cnblogs.com/campus/sdscfz/SF3/homework/12973
这个作业的目标 第12次作业-猜数字游戏

第12次作业

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>猜数字游戏</title>
</head>
<body>
    <script>
        function getRandom(min,max){
            return Math.floor(Math.random()*(max-min+1))+min;
        }
        var random=getRandom(1,10);
        while(true){
            var num=prompt('请输入1~10之间数字:')
            if(num>random){
                alert('猜的大了'); 
            }
            else if(num<random){
                alert('猜的小了');
            }
            else {
                    alert('猜对了');
                    break;
            }
        }
    </script>
</body>
</html>




posted @ 2023-05-23 18:42  puppy3  阅读(13)  评论(0)    收藏  举报