Skip to content

Instantly share code, notes, and snippets.

@Ivannnnn
Created September 22, 2022 21:58
Show Gist options
  • Save Ivannnnn/48b2fc5a1ee9fe36c09d2c847178c7b3 to your computer and use it in GitHub Desktop.
Save Ivannnnn/48b2fc5a1ee9fe36c09d2c847178c7b3 to your computer and use it in GitHub Desktop.
const group = (arr, func) =>
arr.reduce((acc, val) => {
(acc[func(val)] = acc[func(val)] || []).push(val);
return acc;
}, {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment