es-toolkit/docs/reference/string/startCase.md
Deokgyung 7ee48c0e71
Some checks are pending
CI / codecov (push) Waiting to run
Release / release (push) Waiting to run
feat(startCase): add startCase (#203)
* feat: add startCase

* docs: add docs of startCase

* fix: startcase lint error
2024-07-17 22:42:58 +09:00

944 B

startCase

Converts a string to start case.

Start case is a naming convention where the first letter of each word in an identifier is written in uppercase and the rest of the letters are in lowercase, with the words separated by spaces, such as Start Case.

Signature

function startCase(str: string): string;

Parameters

  • str (string): The string to convert to start case.

Returns

(string) The string converted to start case.

Examples

import { startCase } from 'es-toolkit/string';

startCase('--foo-bar--'); // returns 'Foo Bar'
startCase('fooBar'); // returns 'Foo Bar'
startCase('__FOO_BAR__'); // returns 'FOO BAR'
startCase('XMLHttpRequest'); // returns 'XML Http Request'
startCase('_abc_123_def'); // returns 'Abc 123 Def'
startCase('__abc__123__def__'); // returns 'Abc 123 Def'
startCase('_-_-_-_'); // returns ''
startCase('12abc 12ABC'); // returns '12 Abc 12 ABC'