This commit is contained in:
Karan
2021-11-30 18:21:53 +05:30
parent b87492137f
commit 1116181e53
13 changed files with 0 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
const val = "thIs will be capiTalized for each word";
function wordsCaps(str) {
str = str.toLowerCase();
const tempArr = [];
let words = str.split(" ");
words.forEach(word => {
let temp = word.slice(0, 1).toUpperCase() + word.slice(1);
tempArr.push(temp);
});
return tempArr.join(" ");
}
console.log(wordsCaps(val));