Generate two-color ball

let red = []
let blue = 1
function getNum(min, max) {
return Math.floor(Math.random() * (max - min+1) + min)
}
while (red.length < 6) {
red.push(getNum(1, 33))
red = […new Set(red)]
}
blue = getNum(1,16)
console.log(red.sort((a,b)=>a-b).concat(blue))

Guess you like

Origin blog.csdn.net/qq_42975676/article/details/131265643