cwords
v1.0.3
Published
A simple function to count words from a sentence.
Downloads
8
Maintainers
Readme
cwords
A simple npm package to count the number of words in a sentence.
Installation
You can install the cwords package via npm:
npm install cwords
yarn add cwords
Usage
const wordCount = require('cwords');
const sentence = "This is a sample sentence.";
const count = wordCount(sentence);
console.log(count); // Output: 5
API
wordCount(sentence: string): number
sentence: The input sentence for which the word count is to be calculated.
Returns the number of words in the sentence.
Example
const wordCount = require('cwords');
const sentence = "Hello, world! This is a test sentence.";
const count = wordCount(sentence);
console.log(count); // Output: 7