Implement memoize(fn)
The hand-rolled mechanism behind useMemo, React.memo, and every "cache the expensive result" pattern in the Frontend Performance track, build the actual thing this time.
Write memoize(fn) that returns a new function which caches fn's result per unique set of arguments, calling it again with the same arguments should return the cached value without calling fn again.
let calls = 0;
const slowSquare = memoize((n) => { calls++; return n * n; });
slowSquare(4); // computes, calls = 1
slowSquare(4); // cached, calls STILL 1
slowSquare(5); // different args, computes again, calls = 2Hint: you need a way to turn a function's arguments into a single cache key.