Create exercise 1

This commit is contained in:
LSvekis
2021-09-06 11:52:50 -04:00
committed by GitHub
parent 5a2c65f32f
commit 0982735a9c
+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));