JS Utils Kit - v0.5.1
    Preparing search index...

    Function countLines

    • Counts the number of lines in a string.

      Parameters

      • str: string

        The input string.

      Returns number

      Number of lines in the string.

      • Handles Unix (\n), Windows (\r\n), and old Mac (\r) line endings.
      countLines("a\nb\nc");     // 3
      countLines("a\r\nb\r\nc"); // 3
      countLines("hello"); // 1