编辑代码

// 写一个函数,这个函数会返回一个数组,数组里面是 2 ~ 32 之间的随机整数(不能重复),
// 这个函数还可以传入一个参数,参数是几,返回的数组长度就是几

const fn = (len, from = 0, to = 100) => {
    const allNums = Array.from({ length: to - from }, (_, i) => i + from)

    const result = []

    for (let i = len; i-- > 0;) {
        result.push(allNums.splice(Math.floor(Math.random() * allNums.length), 1)[0])
    }
    return result
}

console.log(fn(10, 0, 100))