JS Built-ins
FunctionalProgrammingbeginner

Pure double function

πŸ“– Usage Example
function double(n) { return n * 2; }
double(5); // 10
double(5); // 10 β€” deterministic

Pure functions are deterministic β€” calling them again with the same args gives the same result.

Pure Function β€” Double

Create a pure function that doubles a number without modifying any external state.

Challenge: Implement a double function that takes a number and returns it multiplied by 2.

πŸ’‘ Hints (3)
  • β€’ Use multiplication operator
  • β€’ Pure functions are predictable
  • β€’ No side effects allowed