Skip to content

Instantly share code, notes, and snippets.

@cmwelsh
Forked from anonymous/gist:1714483
Created February 1, 2012 02:09
Show Gist options
  • Save cmwelsh/1714577 to your computer and use it in GitHub Desktop.
Save cmwelsh/1714577 to your computer and use it in GitHub Desktop.
tyebud - pastebin.com/fhFTB3SH
function forEach(array, action) {
for (var i = 0; i < array.length; i++)
action(array[i]);
}
function sum(numbers) {
var total = 0;
function numberProcessor(number) {
total += number;
}
forEach(numbers, numberProcessor);
return total;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment