-3

I am new in Javascript. I have a little problem:

I have a string like this "thisIsATestString".

So how can I make this string to "This Is A Test String"?

3 Answers3

0

Already answered: Convert camelCaseText to Sentence Case Text

You should have searched for "camel case to sentence."

xtc
  • 128
  • 5
-1

This should help to resolve it.

const sentence  = 'thisIsATestString';
const updatedSentenec = (sentence[0].toUpperCase() + sentence.slice(1)).split(/(?=[A-Z])/).join(' ')
Ankur
  • 730
  • 7
  • 28
-2

Try this:

"thisIsATestString".replace(/(^\w|[A-Z])/g, function (match) {
    return ' ' + match.toUpperCase();
}).trim();
Huang Kevin
  • 181
  • 4