Skip to main content

capitalize

The capitalize() function capitalizes the first letter of a string.

Parameters

ParameterTypeDescription
strStringThe string to be capitalized.

Returns

  • String: The capitalized string

Throws

  • Error: if str 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