1 2 3 4 5 6 7 8 9 10 11 12
| const add = (...args) => { let result = [...args].reduce((res, item) => res + item) const next = (..._args) => { result = [..._args].reduce((_res, _item) => { return _res + _item }, result) return next } next.toString = () => result return next } console.log(add(1)(2)(3, 4))
|