1var text = 'helloThereMister';
2var result = text.replace( /([A-Z])/g, " $1" );
3var finalResult = result.charAt(0).toUpperCase() + result.slice(1);
4console.log(finalResult);
1"thisStringIsGood"
2 // insert a space before all caps
3 .replace(/([A-Z])/g, ' $1')
4 // uppercase the first character
5 .replace(/^./, function(str){ return str.toUpperCase(); })
6
1const sentence = 'The quick brown fox jumps over the lazy dog.';
2console.log(sentence.toUpperCase());
3// expected output: "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG."
1String.prototype.toCamelCase = function () {
2 let STR = this.toLowerCase()
3 .trim()
4 .split(/[ -_]/g)
5 .map(word => word.replace(word[0], word[0].toString().toUpperCase()))
6 .join('');
7 return STR.replace(STR[0], STR[0].toLowerCase());
8};