const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1)
capitalize("follow for more")
// Result: Follow for more
const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1)
capitalize("javascript one-liners are fun")
//Javascript one-liners are fun
/**
* Capitalizes first letters of words in string.
* @param {string} str String to be modified
* @param {boolean=false} lower Whether all other letters should be lowercased
* @return {string}
* @usage
* capitalize('fix this string'); // -> 'Fix This String'
* capitalize('javaSCrIPT'); // -> 'JavaSCrIPT'
* capitalize('javaSCrIPT', true); // -> 'Javascript'
*/
const capitalize = (str, lower = false) =>
(lower ? str.toLowerCase() : str).replace(/(?:^|s|["'([{])+S/g, match => match.toUpperCase());
;