Function strCountCharOccurances

  • Counts the number of occurrences of a specific character in a string.

    Parameters

    • input: string

      The string to search within.

    • char: string

      The character to count occurrences of. Must be a single character string of length 1.

    Returns number

    Throws

    If the char parameter is not a single character string of length 1.

    Example

    strCountCharOccurances('hello world', 'o');;
    //=> 2

Generated using TypeDoc