function wait(seconds) {
  return new Promise(resolve => {
    setTimeout(resolve, seconds);
  });
}

function repeat(func, times, s) {
  return async function (...args) {
    for (let i = 0; i < times; i++) {
      func.apply(null, args);
      await wait(s);
    }
  };
}
const repeatFunc = repeat(alert, 4, 2000);

repeatFunc("hellworld");//会alert4次 helloworld,每次间隔3秒