Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80742 views
1
var createCompounder = require('../internal/createCompounder');
2
3
/**
4
* Converts `string` to [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
5
*
6
* @static
7
* @memberOf _
8
* @category String
9
* @param {string} [string=''] The string to convert.
10
* @returns {string} Returns the start cased string.
11
* @example
12
*
13
* _.startCase('--foo-bar');
14
* // => 'Foo Bar'
15
*
16
* _.startCase('fooBar');
17
* // => 'Foo Bar'
18
*
19
* _.startCase('__foo_bar__');
20
* // => 'Foo Bar'
21
*/
22
var startCase = createCompounder(function(result, word, index) {
23
return result + (index ? ' ' : '') + (word.charAt(0).toUpperCase() + word.slice(1));
24
});
25
26
module.exports = startCase;
27
28