Given an array [1, 2, 3, 4], how can I find the sum of its elements? (In this case, the sum would be 10.)
[1, 2, 3, 4]
10
I thought $.each might be useful,
Anyone looking for a functional oneliner like me? Take this:
sum= arr.reduce(function (a, b) {return a + b;}, 0);