Guest User

Untitled

a guest
Jul 22nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. // Math.sum.apply(null, [3, 4, 5, 6]) => 18
  2. Math.sum = function() {
  3. var total = 0, x = 0;
  4. while (x < arguments.length) total += arguments[x++];
  5. return total;
  6. };
  7.  
  8. // Math.avg.apply(null, [3, 4, 5, 6]) => 4.5
  9. Math.avg = function() {
  10. return Math.sum.apply(null, arguments) / arguments.length;
  11. };
Add Comment
Please, Sign In to add comment