capitalize
The capitalize()
function capitalizes the first letter of a string.
Parameters
Parameter | Type | Description |
---|---|---|
str | String | The string to be capitalized. |
Returns
String
: The capitalized string
Throws
Error
: ifstr
is not a valid string
Example
const utils = require('utils-core.js');
const str = 'coding is awesome';
const check = utils.format.capitalize(str);
console.log(check);
//Output: Coding is awesome
const utils = require('utils-core.js');
const str = 'javascript';
const check = utils.format.capitalize(str);
console.log(check);
//Output: Javascript