Prototype: sumSelected(values, predicate) visits each Number once in input order, calls predicate(value, index) once, and sums values for which it returns true. Return 0 for empty input. Stop and propagate a callback exception.

Final: groupBy(values, keyOf) calls keyOf(value, index) exactly once per item in input order and returns a Map. Group keys follow first appearance; each new group array preserves item order and the original item references. Do not mutate inputs. Stop on callback failure and do not invoke later items.

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.