Skip to content

Instantly share code, notes, and snippets.

@haingdc
Created February 28, 2018 10:49
Show Gist options
  • Save haingdc/16c27421a8ba5bbacc234329ee29833f to your computer and use it in GitHub Desktop.
Save haingdc/16c27421a8ba5bbacc234329ee29833f to your computer and use it in GitHub Desktop.
A Gentle Introduction to Functional JavaScript: Part 2
var reduce = function(callback, initialValue, array) {
var output = initialValue;
for (var i = 0; i < array.length; i = i + 1) {
output = callback(output, array[i]);
}
return output;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment