Advertisement
Joeytje50

Untitled

Oct 4th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function sum(arr) {
  2.     var tot = 0;
  3.     for (i=0;i<arr.length;i++) {
  4.         tot += parseFloat(arr[i])||0;
  5.     }
  6.     return tot;
  7. }
  8. sum([1,2,3,4]); // 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement