Create ex1

This commit is contained in:
LSvekis 2021-06-29 19:08:43 -04:00 committed by GitHub
parent ece257bdd3
commit f30e0f1b49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

11
Chapter 11/ex1 Normal file
View File

@ -0,0 +1,11 @@
const val = "world hello this will be capitalized for each word";
function wordsCaps(str) {
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));