Skip to content

Instantly share code, notes, and snippets.

@heapwolf
Created July 19, 2012 17:38
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 heapwolf/3145551 to your computer and use it in GitHub Desktop.
Save heapwolf/3145551 to your computer and use it in GitHub Desktop.
intro/closures
var parcels = [2, 5, 10, 42, 67, 78, 89, 120];
var sum = 0;
function sumParcel(parcel) {
sum += parcel;
}
parcels.forEach(sumParcel);
console.log('sum: ' + sum);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment