Last active
February 8, 2022 08:22
-
-
Save JimOfLeisure/88650e11d479ab552cfd7001ef6fa847 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countLanguages(list) { | |
return list.reduce((p, c) => { | |
if (p[c.language]) p[c.language] += 1 | |
else p[c.language] = 1; | |
return p; | |
}, {}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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