titleCase

Converts the string to title case.

This function capitalizes the first letter of the string and the first letter of every word after a space. It first trims any leading or trailing whitespace and converts the entire string to lowercase before applying the title case logic.

Examples:

  • "hello world" becomes "Hello World"

  • " first name " becomes "First Name"

  • "singleword" becomes "Singleword"

Return

The title-cased version of the string. Returns the original string if it is blank after trimming.