I trying to make next with closure:
function func(number) {
var result = number;
var res = function(num) {
return result + num;
};
return res;
}
var result = func(2)(3)(4)(5)(3);
console.log(result); // 17
I need to receive 2 + 3 + 4 + 5 + 3 = 17 But I got an error: Uncaught TypeError: number is not a function
arguments.length.()at the end of the chain? Yea, that'd be a clever way to annoy your co-workers.func(2, 3, 4, 5, 3)and rework your function to accommodate that setup? Although you have a simple example, it kinda makes more sense to head this way instead of continually invoking a function?...