textConvert
    Preparing search index...

    Function countSentences

    • Counts the number of sentences in a string. Sentences are defined as sequences of text ending with ., !, or ? followed by whitespace or end of string. Text without any sentence-ending punctuation is considered to be a single sentence.

      Parameters

      • text: string

        String input to count sentences from

      Returns number

      Number of sentences in the string

      countSentences('Hello world! How are you?'); // 2