Skip to content

Instantly share code, notes, and snippets.

@da-n
Created March 1, 2013 04:22
Show Gist options
  • Save da-n/5062463 to your computer and use it in GitHub Desktop.
Save da-n/5062463 to your computer and use it in GitHub Desktop.
Sum of integer values in an array using jQuery. Credit: gion_13 Source: http://stackoverflow.com/a/8550489/695454
$.sum_arr_int = function (arr) {
var r = 0;
$.each(arr, function (i, v) {
r += v;
});
return r;
};
var sum = $.sum_arr_int([20, 40, 80, 400]);
console.log(sum);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment