textConvert
    Preparing search index...

    Function countWords

    • Counts the number of words in a string. Words are defined as sequences of letters, numbers, and apostrophes separated by whitespace.

      Parameters

      • text: string

        String input to count words from

      Returns number

      Number of words in the string

      countWords('Hello, world!'); // 2