codetrix - v1.5.0
    Preparing search index...

    Function countOccurrence

    • Counts how many times a character appears in a string.

      Parameters

      • str: string

        The string to search.

      • char: string

        The character to count.

      Returns number

      The number of occurrences.

      countOccurrence('hello world', 'l'); // 3