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,
var totally = eval(arr.join('+'))
That way you can put all kinds of exotic things in the array.
var arr = ['(1/3)','Date.now()','foo','bar()',1,2,3,4]
I'm only half joking.