JS Built-ins
FunctionalProgrammingbeginner

Pure add function

πŸ“– Usage Example
function add(a, b) { return a + b; }
add(2, 3); // always 5 β€” no side effects

A pure function always returns the same output for the same input and has no side effects.

Pure Functions

A pure function always returns the same output for the same input and has no side effects. It doesn't modify external state or depend on it.

Challenge: Implement a pure add function that takes two numbers and returns their sum.

πŸ’‘ Hints (3)
  • β€’ Pure functions have no side effects
  • β€’ Same input always gives same output
  • β€’ No external state manipulation