function groupBy(array, keyFn) {
return array.reduce((accumulator, value) => {
const key = keyFn(value);
if (!accumulator[key]) {
accumulator[key] = [value];
} else {
accumulator[key] = [value];
}
return accumulator;
}, {});
}