1. Home
  2. Docs
  3. Demos
  4. Word Counter

Word Counter

Using Polypad this script gets the total number of words from your text.

How to use Word Counter?

Using the Word Counter script with Polypad is very easy. Let’s say we have some text string that we would like to get the total word count. Simply paste the text down below into Polypad.

The quick brown fox jumps over the lazy dog

Press cmd/ctrl + p depending on your operating system and search for the Word Counter script and select it. The expected output should read:

9 Words

Word Counter Code

function main(input) {
    let words = input.text.trim().match(/\S+/g)
    input.text = `${words && words.length || 0} words`;
}

To learn more about Word Counter, please visit our blog

Tags , ,
Was this article helpful to you? Yes No

How can we help?