SOURCE

function flatten(arr) {
    const res = []
    function step(n) {
        for (const i of n) {
            if (!Array.isArray(i)) {
                res.push(i)
            } else {
                step(i)
            }
        }
    }
    step(arr)
    return res
}
function flatten(arr){
    let res = []
    for(const item of arr){
        if(!Array.isArray(item)){
            res.push(item)
        }else{
           res =  res.concat(flatten(item))
        }
    }
    return res
}
const test =[1,2,3,[1,[2]]]
console.log(flatten(test))


function dividePacket(totalMoney,totalCount){
    let leftMoney =totalMoney
    let leftCount = totalCount;
    let arr = []
    for(let i = 0;i<totalCount-1;i++){
        let money = Math.max(parseFloat(Math.random()*(leftMoney/leftCount*2)).toFixed(2), 0.01)
        arr.push(money)
        leftMoney-=money
        leftCount--
    }
    arr.push(parseFloat(leftMoney).toFixed(2))
    console.log(arr)
}

dividePacket(6,6)

//手写 输入一个Url 获得参数的正则 

const arrrr = [1,2,3]
const rr = arrrr.forEach((item)=>{
    return item*2
})
console.log(rr)
console 命令行工具 X clear

                    
>
console