var str = "You seE whaT you believe!"
function changeStr(str) {
var arr = str.toLowerCase().split(" ");
arr.forEach((item, index, array) => {
arr[index] = item[0].toUpperCase() + item.substring(1, item.length);
});
return arr.join(" ");
}
console.log(changeStr(str)); //You See What You Believe!ascript
var str = "You seE whaT you believe!"
function changeStr(str) {
var arr = str.toLowerCase().split(" ");
arr.forEach((item, index, array) => {
arr[index] = Array.prototype.map.call(item, function(v, i) {
return i == 0 ? v.toUpperCase() : v;
}).join("");
});
return arr.join(" ");
}
console.log(changeStr(str)); //You See What You Believe!
网友评论