JS Built-ins
FunctionalProgrammingintermediate

Reusing curried functions

πŸ“– Usage Example
const log = level => msg => '[' + level + '] ' + msg;
const warn = log('WARN');
warn('Low memory'); // '[WARN] Low memory'

Curried loggers let you partially apply the log level for reuse throughout the codebase.

Composing with Curried Functions

Curried functions are powerful when reused in different contexts.

Challenge: Create a curried power function and use it to create square and cube functions.

πŸ’‘ Hints (3)
  • β€’ Use Math.pow for exponentiation
  • β€’ power(2) creates a square function
  • β€’ power(3) creates a cube function