I want to make a function to retry calling callback n times until it return TRUE;
Here's my current code:
function RetryX(callback, delay, retries) {
(function wait() {
if( callback() !== true && --retries > 0 ){
setTimeout(wait, delay);
}
}());
}
Question:
- Is it correct way to do it?
- Is there any way to optimize it?
- Can it be modified to pass jslint? currently it shows "unexpected --retries"