简单抽奖

tomcat2022 / 2023-08-21 / 原文

<html>
    <head>
       
    </head>
    <body>
       
    </body>
    <script>
        function getRandom(N,M){
            return Math.floor(Math.random()*(M-N+1))+N
        }
        let random=getRandom(1,10);
        console.log(random)
        while(true){
            let num=+prompt('请你输入您猜的数字:')
            if(num>random){
                alert('你猜大了啊')
            }else if(num<random){
                alert('你猜小了啊')
            }else{
                alert('猜对了,真厉害')
                break;
            }
        }
      </script>
   </table> 
</html>