Skip to content

Instantly share code, notes, and snippets.

@nuxodin
Created February 14, 2023 23:17
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nuxodin/ae6b13c0f8c0d1c381b41c2b8605ba24 to your computer and use it in GitHub Desktop.
tryAgain function
function tryAgain(fn, times = 2){
try {
return fn(times);
} catch (e) {
if (times > 1) return tryAgain(fn, times-1);
throw e;
}
}
tryAgain( n => {
console.log(n+' trys left')
afsefesf();
}, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment