Complete useMemo Call
Fill in the Blank Medium
Question
Fill in the blank to cache the sorted result.
Code
const sorted = _____(() => items.sort((a, b) => a - b), [items]);
Hint
This Hook caches a computed value.
Explanation
useMemo caches the result of the calculation function. It only recomputes when the dependencies (items) change, avoiding the expensive sort on every render.
Related Resources
Related Lessons
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.