UNPKG

ds-algo-study

Version:

Just experimenting with publishing a package

32 lines (25 loc) 938 B
/*********************************************************************** Write a function named: lazyAdder(firstNum). The lazyAdder function will accept a number and return a function. When the function returned by lazyAdder is invoked it will again accept a number, (secondNum), and then return a function. When the last mentioned function is invoked with a number, (thirdNum), it will FINALLY return a number. See below for examples! Example 1: let firstAdd = lazyAdder(1); let secondAdd = firstAdd(2); let sum = secondAdd(3); console.log(sum); // prints 6 Example 2: let func1 = lazyAdder(10); let func2 = func1(20); let total = func2(3); console.log(total); // prints 33 ***********************************************************************/ function lazyAdder(firstNum) { return function (secondNum) { return function (thirdNum) { return firstNum + secondNum + thirdNum; }; }; } module.exports = lazyAdder;