Skip to main content

Practice · 1 of 3

Hand-Rolled Spy

CHALLENGE
Difficulty: intermediate+25 XP

Write makeSpy(impl) returning a function that records every call: spy.calls is an array of argument-arrays, newest last. If impl is provided, each call forwards to it and returns its result; without impl it returns undefined. Also record return values in spy.results, and add spy.reset() which clears calls.

Back to lesson: Practice: Seams & Doubles — Practice