Skip to content

Instantly share code, notes, and snippets.

@jabley
Created February 23, 2012 10:48
Show Gist options
  • Save jabley/1892225 to your computer and use it in GitHub Desktop.
Save jabley/1892225 to your computer and use it in GitHub Desktop.
Javascript function to iterate an array of functions, returning the first truthy result
function findResult(fns, args, fallback) {
var result;
for (var i = 0; i < fns.length; ++i) {
result = fns[i].apply(null, args);
if (result) {
return result;
}
}
return fallback;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment