Capitalize a string

JavaScript version
const capitalize = (str) => `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
// Or
const capitalize = ([first, ...rest]) => `${first.toUpperCase()}${rest.join('')}`;
TypeScript version
const capitalize = (str: string): string => `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
// Or
const capitalize = ([first, ...rest]: string): string => `${first.toUpperCase()}${rest.join('')}`;
Examples
capitalize('hello world'); // 'Hello world'