Skip to main content

Decapitalize a string

JavaScript version

const decapitalize = (str) => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;

// Or
const decapitalize = ([first, ...rest]) => `${first.toLowerCase()}${rest.join('')}`;

TypeScript version

const decapitalize = (str: string): string => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;

// Or
const decapitalize = ([first, ...rest]: string): string => `${first.toLowerCase()}${rest.join('')}`;

Examples

decapitalize('Hello world'); // 'hello world'

Comments