Course · Section 17: Modern JavaScript Development: Modules, Tooling, and Functional · Lecture 294: Declarative and Functional JavaScript Principles
To render a list split into sections, group rows by a field first. Implement `groupBy(items, key)` returning an object mapping each distinct value of `item[key]` to an array of the items that have it, preserving input order.
+ 1 hidden test run on Submit.
A single reduce builds a map from group value to its members. Lazily initializing each bucket the first time it appears keeps the first-seen ordering, which is what a sectioned list renders.
Run your code to see results.