DEV Community

Cover image for helloWorld to Hello World
Temitope Ayodele
Temitope Ayodele

Posted on

helloWorld to Hello World

To convert camelCase string to Title Case (ES6)

const convertCamelToTitleCase = (camelCase) =>
  camelCase
    .replace(/([A-Z])/g, (match) => ` ${match}`)
    .replace(/^./, (match) => match.toUpperCase())


//Example: convertCamelToTitleCase('todayILearned')
//Result: Today I Learned
Enter fullscreen mode Exit fullscreen mode

Discussion (0)