fast-sum
Version:
This node module is used to add multiple numbers
19 lines • 593 B
JavaScript
;
exports.__esModule = true;
exports.sum = void 0;
function sum() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return args.reduce(function (preVal, currNumber) {
if (preVal === void 0) { preVal = 0; }
if (typeof preVal === "string")
throw new Error(preVal + " is not a number");
if (typeof currNumber === "string")
throw new Error(currNumber + " is not a number");
return preVal + currNumber;
});
}
exports.sum = sum;
//# sourceMappingURL=sum.js.map