JS Built-ins
FunctionalProgrammingadvanced

Currying 3-argument functions

πŸ“– Usage Example
const add = a => b => a + b;
const add10 = add(10);
[1, 2, 3].map(add10); // [11, 12, 13]

Partially applied functions work directly as callbacks in array methods.

Advanced Currying

Currying can be extended to functions with more than 2 arguments.

Challenge: Implement a curried sum3 function that adds three numbers when called as sum3(a)(b)(c).

πŸ’‘ Hints (3)
  • β€’ Each parameter level returns a function
  • β€’ Three parameters means three nested arrow functions
  • β€’ The innermost function performs the addition