美文网首页
js随机生成双色球

js随机生成双色球

作者: 一代码农1970 | 来源:发表于2020-09-28 14:04 被阅读0次
function sleepfox() {
            let list = [];
            while (list.length < 7) {
                let number = Math.ceil(Math.random() * (list.length != 7 ? 33 : 16));
                if (!list.includes(number)) { // 生成的随机数不能重复
                    list.push(number)
                }
            }
            let red = list.slice(0, 6).sort((a, b) => a - b); // 红色
            let blue = list.slice(6, 7); // 蓝色
            return [...red, ...blue]
        }

每期随机打5注 中1000万,就不用敲代码了。

通过自己的技术改变自己的命运。

相关文章

网友评论

      本文标题:js随机生成双色球

      本文链接:https://www.haomeiwen.com/subject/bhpduktx.html