query
On this page

toSentenceCase

lib.toSentenceCase

Docs pulled from | This Revision | 10 minutes ago


Converts the first character of a string s to upper-case.

Inputs

str
The string to convert to sentence case.

Type

toSentenceCase :: string -> string

Examples

lib.strings.toSentenceCase usage example

toSentenceCase "home"
=> "Home"
(lib.strings.toSentenceCase)

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

toSentenceCase =
    str:
    lib.throwIfNot (isString str)
      "toSentenceCase does only accepts string values, but got ${typeOf str}"
      (
        let
          firstChar = substring 0 1 str;
          rest = substring 1 (stringLength str) str;
        in
        addContextFrom str (toUpper firstChar + toLower rest)
      );