How to convert a string to sentence case

You, JavaScriptES6
Back

This is a small script to make your string Sentence Case this also can easily be modified to use string to convert to CamelCase, PascalCase or Title Case.

const camelSentence = string =>
  string
    .toLowerCase()
    .trim()
    .split(/[.\-_\s]/g)
    .reduce(
      (str, word) =>
        `${str[0].toUpperCase()}${str.slice(
          1,
        )} ${word[0].toUpperCase()}${word.slice(1)}`,
    );
© Heshan Wanigasooriya.RSS

🍪 This site does not track you.