Implement a function usePrevious(value) that stores and returns the previous value of a variable.
The function should:
undefined if called for the first time.Examples
const prev = usePrevious(1); // undefined const prev2 = usePrevious(2); // 1
JavaScript Function
No test results yet
Click "Run" to execute tests