About js Corey encountered a problem when doing a pen test.

Please implement the test2 function to meet the following four conditions to pass the test, complete it in the most concise way, and guarantee the code quality
module.exports.test2 = (input) = > {
}

(1) test2 () = 0
(2) test2 (1) () = 1
(3) test2 (1) (2) (3) (4) () = 10
(4) const T2 = test2 (1) (2); T2 (3) () = 6; T2 (4) () = 7
) I wrote a function, but I can only meet the first three conditions, ask God for advice, how to meet these four conditions at the same time, I do not know how to write.


The

title has given the signature of the function, so the answer should not be changed without authorization.

var add = function() {
    var _this = this,
    _args = arguments
    return function() {
        if (!arguments.length) {
            var sum = 0;
            for (var i = 0,c; c = _args[iPP];) sum += c
            return sum
        } else {
            Array.prototype.push.apply(_args, arguments) 
            return arguments.callee
        }
    }
}
Menu