kstoyanov

06. * Functional Sum

Oct 9th, 2020 (edited)
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function () {
  2.   let sum = 0;
  3.   const result = (num) => {
  4.     sum += num;
  5.     result.valueOf = () => sum;
  6.     return result;
  7.   };
  8.   return result;
  9. }());
Advertisement
Add Comment
Please, Sign In to add comment