SyntaxStudy
Sign Up

Memoize Function

JAVASCRIPT Hard +50 XP
Problem Description
Write a function `memoize(fn)` that returns a memoized version of `fn`. A memoized function caches its results — if called again with the same arguments, it returns the cached result instead of recomputing.

Example:
const slow = (n) => { /* expensive */ return n * 2; };
const fast = memoize(slow);
fast(5); // computes → 10
fast(5); // returns cached → 10 (no recompute)
Your Solution