How to implement a locking function for multiplying an arbitrary number of numbers.
Example of a call:
multiply(1)(2)(3)(4)(5) // 120
To accomplish this task, it is necessary to redefine the toString
method for the internal function, which should return the accumulated result, but I had result NaN
.
function Multiply(arguments) {
for (var i = 0; i < arguments.length; i++) {
var number = arguments.length[i];
}
return function(res) {
return number * res.valueOf();
};
}
console.log(Multiply(5)(5)(6)(8));