JavaScript interview: Implement memoize
easy
closures
caching
Write memoize(fn). The returned function calls fn the first time it sees a set of arguments and returns the cached result after that.
Treat calls as the same when their arguments are the same primitive values in the same order. f(1, 2) and f(2, 1) are different calls. Cached undefined results count too.
Your code
Runs in a Web Worker in your browser. Tests use real timers, so a run takes a second or two.