cwords

1.0.3 • Public • Published

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

Package Sidebar

Install

npm i cwords

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

2.81 kB

Total Files

4

Last publish

Collaborators

  • istiak_rahman