Arrays & Objects

Group By Polyfill

easyJS SpecificJS / TS6 tests

Problem Statement

Write a method or function `groupBy(array, fn)` that splits an array into an object grouped by the key returned from `fn(item)`.

Examples

Example:
groupBy([6.1, 4.2, 6.3], Math.floor) -> { '4': [4.2], '6': [6.1, 6.3] }
JavaScript & TypeScript starter code included
Run this as a live interview

Practice solo

6 test cases. No second person needed.

Get new interview exercises

Practice problems and review drills, sent when we publish new ones. No spam.

Unsubscribe anytime. We never share your address.