SheetXL - v0.3.20
    Preparing search index...
    • Capitalizes the first character of a string and optionally lowercases the rest of the string.

      Parameters

      • str: string

        The input string to be processed.

      • lowerCaseRest: boolean = false

        A boolean flag indicating whether to convert the rest of the string to lowercase. If true, the remaining characters (after the first) will be converted to lowercase. If false, the remaining characters will remain unchanged.

      Returns string

      A new string with the first character capitalized and the rest lowercased if the lowerCaseRest flag is true. If the lowerCaseRest flag is false, only the first character is capitalized, and the rest of the string remains unchanged.

      capitalize("hello");           // Returns "Hello"
      capitalize("hello", true); // Returns "Hello"
      capitalize("HELLO", true); // Returns "Hello"
      capitalize("123abc", true); // Returns "123abc"
      capitalize("", true); // Returns ""