Prototype: implement generator range(start, end), yielding safe-integer Numbers from start inclusive to end exclusive. Both endpoints must be safe integers with start <= end, or throw RangeError when consumed. Equal endpoints yield nothing.

Final: implement generator take(iterable, limit). limit is a nonnegative safe integer or throws RangeError when consumed. Yield at most limit values lazily, without reading one extra. Close an opened source on early completion, consumer break, or failure. limit=0 must not open the source iterator. Preserve yielded object identity.

Complete the exported stubs in exercise.mjs. The prototype and final stages have separate checks.

Shell
node main.mjs --stage prototype
node main.mjs --stage final

Use Node.js 20+ locally, or the website's browser worker. Tests are standard-library only and check the documented behavior; they do not prove performance or force garbage collection.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.