Skip to content

dashdashzako/count-words

Repository files navigation

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

  1. Do not handle non string parameter
  2. From a text that can be of any shape (single, multiline)
  3. Separate all words
  4. Filter them by length
  5. 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 }

About

Counting words. With elegance.

Resources

Stars

Watchers

Forks

Packages

No packages published