Posted By

cfleschhut on 05/30/09


Tagged

javascript function


Versions (?)

add up any number of parameters


 / Published in: JavaScript
 

just testing snipplr.com

  1. function sum() {
  2. var res = 0;
  3. for (var i=0; i < arguments.length; i++) {
  4. res += arguments[i];
  5. }
  6. return res;
  7. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: mrhoo on June 2, 2009

function sum(){ return eval([].join.call(arguments,'+')); }

You need to login to post a comment.