<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>
标签:抽奖,getRandom,random,num,let,简单,Math From: https://www.cnblogs.com/tomcat2022/p/17644863.html