我给出最后一题我的正确实现

function repeat(func, times, wait) {
    function set(f) {
        let timer
        let count = 1
        let print = () => {
            timer = setTimeout(() => {
                func(f)
                if (count >= times) {
                    clearTimeout(timer)
                    return
                }
                print(f)
                count++

            }, wait)
        }
        print()
    }

    return set
}


// 输入
let log = console.log
const repeatFunc = repeat(log, 4, 3000);

// 输出
// 会alert4次 helloworld, 每次间隔3秒
repeatFunc('hellworld');
repeatFunc('1111')