JS Built-ins
FunctionalProgrammingintermediate

Multiplier factory β€” function returning function

πŸ“– Usage Example
function multiplier(factor) {
  return x => x * factor;
}
const double = multiplier(2);
double(5); // 10

A function factory returns a specialized function β€” a classic higher-order pattern.

Factory Functions

A factory function returns new functions with customized behavior.

Challenge: Create a multiplierFactory function that returns a new function. Each returned function multiplies its argument by a specific factor.

πŸ’‘ Hints (3)
  • β€’ Factory returns a function
  • β€’ The returned function closes over factor
  • β€’ Each call to factory creates a new function