Skip to main content

Practice ยท 3 of 3

Memoize with a Map

Write memoize(fn) that returns a cached version of a single-argument function. Calling the returned function with an argument it has seen before must return the remembered result **without calling fn again**. Store previous results in a Map closed over by the wrapper.

Difficulty: intermediate

Back to lesson: Practice: Closures โ€” Practice