Skip to content

Instantly share code, notes, and snippets.

@sungwon
Created August 29, 2016 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sungwon/b7b3fe33e36916b1800529d146baa9fe to your computer and use it in GitHub Desktop.
Save sungwon/b7b3fe33e36916b1800529d146baa9fe to your computer and use it in GitHub Desktop.
eloquent js
var numbers = [1, 2, 3, 4, 5], sum = 0;
function forEach(array, action) {
for (var i = 0; i < array.length; i++)
action(array[i]);
}
forEach(numbers, function(number) {
sum += number;
})};
console.log(sum);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment