Skip to content

Instantly share code, notes, and snippets.

@JimOfLeisure
Last active February 8, 2022 08:22
Show Gist options
  • Save JimOfLeisure/88650e11d479ab552cfd7001ef6fa847 to your computer and use it in GitHub Desktop.
Save JimOfLeisure/88650e11d479ab552cfd7001ef6fa847 to your computer and use it in GitHub Desktop.
function countLanguages(list) {
return list.reduce((p, c) => {
if (p[c.language]) p[c.language] += 1
else p[c.language] = 1;
return p;
}, {})
}
const countLanguages = list => list.reduce((a, {language}) => (a[language] = (a[language] || 0) + 1) && a, {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment