Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2.  
  3. function test(...args) {
  4.     args = Array.prototype.slice.call(args);
  5.  
  6.     let result = function (...args2) {
  7.         return test.apply(test, args.concat(Array.prototype.slice.call(args2)));
  8.     };
  9.  
  10.     result.toString = function () {
  11.         return Array.prototype.slice.call(args).reduce((accum, item) => accum + item, 0);
  12.     };
  13.  
  14.     return result;
  15. }
  16.  
  17. console.log('SUM ' + test(1, 2, 3)(4, 5, 6)(7, 8, 9));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement