Created
March 4, 2023 22:15
-
-
Save Git-I985/775125efd0a14776fd04e9f3e32b9bb1 to your computer and use it in GitHub Desktop.
JS Words count
This file contains 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
export default (_words) => { | |
const words = _words.split(' ').map(word => word.toLowerCase()).filter(Boolean); | |
return [...new Set(words)].reduce((acc, word) => ({ ...acc, [word]: words.filter(_word => _word === word).length}), {}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment