```js function mySetInterval(fn, a, b){ let timer = null let count = 0 let timestamp // 设置定时器 function set(){ const step = count % 3 switch(step){ case 0: timestamp = a; break; case 1: timestamp = a + b break; case 2: timestamp = a + 2 * b break; } timer = setTimeout(()=>{ fn() count++ set() }, timestamp * 1000) } // 清除定时器 function clear(){ timer && clearTimeout(timer) } set() return clear } function out(){ console.log(new Date().getSeconds()) } const clear = mySetInterval(out,1,2) setTimeout(()=>{clear()},20000) ```