Skip to content

Instantly share code, notes, and snippets.

@PatheticMustan
Created April 30, 2021 23:17
Show Gist options
  • Save PatheticMustan/67602461d0e91575777583a7730b9f74 to your computer and use it in GitHub Desktop.
Save PatheticMustan/67602461d0e91575777583a7730b9f74 to your computer and use it in GitHub Desktop.
countdown go wheeeee
const repeatTask = (func=()=>{}, ms=100, repeats=1) => {
let interval = setInterval(() => {
if (--repeats === 0) clearInterval(interval);
func(repeats);
}, ms);
}
repeatTask((i)=>console.log(i), 1000, 5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment