wordcount.js
v1.0.1
Published
a simple module to count the amount of words in a supplied string
Downloads
4
Readme
wordcount.js
An NPM module for counting words
Usage
Using wordcount.js is easy, just require it and call the function with a string.
var wordcount = require('wordcount.js');
var sentence = "Hello World, I'm Jim";
var wordcount = wordcount(sentence);
console.log(wordcount); // 4
You can also pass an array of strings using wordcount#countMultiple
as shown below.
var wordcount = require('wordcount.js');
var strings = ["Hello, World", "Hi I'm Bob", "npm is the package manager for Node.js. It was created in 2009 as an open source project to help JavaScript developers easily share packaged modules of code."]
console.log(wordcount.countMultiple(strings)); // [ 2, 3, 27 ]