Posted By

Leech on 07/21/06


Tagged

arrays


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jkochis


Sum v1.0


 / Published in: JavaScript
 

URL: http://jsfromhell.com/array/sum

Sum all the elements of a numeric array. Created: 2005.11.04

  1. /*
  2. **************************************
  3. * sum Function v1.0 *
  4. * Autor: Carlos R. L. Rodrigues *
  5. **************************************
  6. */
  7. sum = function(o){
  8. for(var s = 0, i = o.length; i; s += o[--i]);
  9. return s;
  10. };

Report this snippet  

You need to login to post a comment.