Posted By

EvanHahn on 03/17/12


Tagged

array sum


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

cmoody21
spee66


Sum array


 / Published in: JavaScript
 

URL: http://evanhahn.com/?p=663

Basically, this creates a string expression of all of the array values added up (eg, 1+2+3) and then evaluates it with eval.

  1. var sum = eval(arrayToSum.join('+'));

Report this snippet  

You need to login to post a comment.