Created
April 11, 2015 14:58
-
-
Save IPRIT/2a2018bf4c2881db00ed to your computer and use it in GitHub Desktop.
Reduce example
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
| var util = require('util'); | |
| function countWords(inputWords) { | |
| return inputWords.reduce(function (prev, cur) { | |
| prev[cur] = ++prev[cur] || 1; | |
| return prev; | |
| }, {}); | |
| } | |
| module.exports = countWords; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment