Skip to content

Instantly share code, notes, and snippets.

@hyonschu
Created May 27, 2013 21:20
Show Gist options
  • Save hyonschu/5659145 to your computer and use it in GitHub Desktop.
Save hyonschu/5659145 to your computer and use it in GitHub Desktop.
function reduce(ary, fn, result) {
for (var i=0; i<ary.length; i++) {
fn(result,ary[i]);
result+=ary[i]+"!";
}
return result;
}
reduce(["A", "B", "C"], function(memo, num){ return memo + num; }, "");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment