var arr=[]; for(var i=0;i<3;i++){ getLuckyNum(); } function getLuckyNum(){ ._1到9选3个不重复的组合js">
赞
踩
- <!DOCTYPE html>
- <html>
- <head>
- <title>随机数-生成1-9三个互不相同的幸运数</title>
- <script type="text/javascript">
- var arr=[];
- for(var i=0;i<3;i++){
- getLuckyNum();
- }
- function getLuckyNum(){
- do{
- Random=Math.floor(Math.random()*9)+1;
- } while(arr.indexOf(Random)!=-1)
- arr.push(Random);
- }
- console.log(arr)
- </script>
- </head>
- <body>
- </body>
- </html>

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。