ds-algo-study
Version:
Just experimenting with publishing a package
29 lines (18 loc) • 734 B
JavaScript
/***********************************************************************
Write a function named `dynamicDivide(divisor)`. The dynamicDivide function will
return a new function that when invoked will divide the argument number by the
divisor.
Look below to see how this function is invoked:
const halfer = dynamicDivide(2); // returns a function
halfer(20); // returns 10
const divideByThree = dynamicDivide(3);
divideByThree(30); // returns 10
const divideByFive = dynamicDivide(5);
divideByFive(50); // returns 10
***********************************************************************/
function dynamicDivide(divisor) {
return function (dividend) {
return dividend / divisor;
};
}
module.exports = dynamicDivide;