Write memoize(fn) returning a wrapped function that remembers results.
Calling the wrapper twice with the same arguments must call fn only once and return the stored answer the second time.
Build the cache key from the arguments with JSON.stringify. That has real limits - it cannot tell one function from another, and key order matters - but it is the right tool for arguments that are numbers, strings and plain data.