Skip to content

Instantly share code, notes, and snippets.

@infantiablue
Last active December 22, 2015 17:29
Show Gist options
  • Save infantiablue/6506359 to your computer and use it in GitHub Desktop.
Save infantiablue/6506359 to your computer and use it in GitHub Desktop.
JavaScript: Array Handler
function forEach(array, action) {
for (var i = 0; i < array.length; i++)
action(array[i]);
}
// Example
function sum(numbers) {
var total = 0;
forEach(numbers, function (number) {
total += number;
});
return total;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment