Create ex1
This commit is contained in:
parent
ece257bdd3
commit
f30e0f1b49
11
Chapter 11/ex1
Normal file
11
Chapter 11/ex1
Normal 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));
|
||||
Loading…
x
Reference in New Issue
Block a user