strings.toTitle() function

The strings.toTitle() function converts all characters in a string to title case.

*Output data type: String*

  1. import "strings"
  2. strings.toTitle(v: "a flux of foxes")
  3. // returns "A FLUX OF FOXES"

Parameters

v

The string value to convert.

*Data type: String*

Examples

Covert characters in a string to title case
  1. import "strings"
  2. data
  3. |> map(fn: (r) => ({ r with pageTitle: strings.toTitle(v: r.pageTitle) }))

The difference between toTitle and toUpper

The results of toTitle() and toUpper are often the same, however the difference is visible with special characters:

  1. str = "dz"
  2. strings.toTitle(v: str) // Returns Dz
  3. strings.toUpper(v: str) // Returns DZ

Related articles