SOURCE

function getNumber (){
    let redball =[];
    let blueBall=[]
    for(let i=0;i<6;i++){
        const redBallNum =Math.floor(Math.random()*32+1)
        if(redball.indexOf(redBallNum)===-1){
            redball.push(redBallNum)
        }else{
            i--
        }
    } 
    for(let i=0;i<1;i++){
        const blueBallNum =Math.floor(Math.random()*32+1)
        if(blueBall.indexOf(blueBallNum)===-1){
            blueBall.push(blueBallNum)
        }else{
            i--
        }
    }
    return `红球:${redball.join(',')},篮球: ${blueBall.join(',')}`
}
console.log(getNumber ())
console 命令行工具 X clear

                    
>
console