@dashdashzako/count-words
v2.0.2
Published
Counting words. With elegance.
Downloads
11
Readme
Count Words
The problem
Implement a function that returns an object with words as keys and occurencies
countWords(string, n)
as values for each word longer than n.
The solution
- Do not handle non string parameter
- From a text that can be of any shape (single, multiline)
- Separate all words
- Filter them by length
- Initialise or increment the count key in the final object
Install and run
npm install @dashdashzako/word-count
import countWords from 'count-words';
const theText = 'Hello, World!';
console.log(JSON.stringify(theText));
// { hello: 1, world: 1 }