FirstsCaps

Lowercase the string and adds a capital letter to the first letter of each word in the string. Optionally add the capital letter even after a character (or sequence of characters) other than space.

Example 1
stringToCaps: the cup is on the table
RETURN: The Cup Is On The Table

Example 2
stringToCaps: heLLo WORLD
RETURN: Hello World

**Example 3 (typical case) **
stringToCaps: giuseppe d’amico
separatorChar: ’
RETURN: Giuseppe D’Amico

Use case
Often when submitting a form, some users hastily omit the capital letter in their name, or write it all in uppercase. So it is bad to repeat their name in the APP in the same way it was wrongly written.

Note
This function can also be performed in CSS, but if the data is to be transmitted externally to the APP, the same result would not be obtained.
This function could certainly be improved by using regular expressions.

To fork: FirstsCaps - Replit

7 Likes