Skip to content

Instantly share code, notes, and snippets.

@shinout
Created July 27, 2011 08:39
Show Gist options
  • Save shinout/1108934 to your computer and use it in GitHub Desktop.
Save shinout/1108934 to your computer and use it in GitHub Desktop.
for loop with error limit
var total = 1000;
var err_limit = 10;
for (var i=0, e=0; i<total && e<err_limit; i++) {
if (Math.random() > 0.750) {
console.log("error");
e++;
i--;
}
else {
console.log("ok");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment