Yolo Group interview question

How to implement something like useMemo in JavaScript?