// 普通low版
String.prototype.toJadenCase = function () {
var arr = this.split(" ");
var str = "";
for (var i = 0; i < arr.length; i++) {
var cap = arr[i].charAt(0).toLocaleUpperCase();
arr[i] = arr[i].replace(/w{1}/, cap);
if (!str) {
str += arr[i];
} else {
str = str + " " + arr[i]
}
}
return str;
};
var str = "How can mirrors be real if our eyes aren't real";
console.log(str.toJadenCase())
// 正则高大上版本
String.prototype.toJadenCase = function () {
return this.replace(/(w)(w+)/g,function(a,b,c){
return b.toUpperCase() + c;
})
};
var str = "How can mirrors be real if our eyes aren't real";
console.log(str.toJadenCase())