Rows have {id: string, tags: string[]}. IDs are nonempty and unique where required; inputs in this exercise otherwise follow that shape.

Prototype: copyRows(rows) returns fresh row objects with fresh tag arrays, preserving order and duplicates in tags. Input and output mutations must be independent.

Final: indexById(rows) returns a Map from ID to an owned row snapshot, in input insertion order. Reject duplicate or empty IDs with RangeError and preserve all inputs, including on rejection. Each call creates an independent result.

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.