Skip to content

Commit 4dff23e

Browse files
committed
Title Case
1 parent 3f524bb commit 4dff23e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

6_Title-Case/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Title Case
2+
// Write a function that takes in a string (sentence) and capitalizes the first letter of each word
3+
4+
const titleCase = str => {
5+
return str
6+
.split(' ')
7+
.map(word => {
8+
return word.replace(word[0], word[0].toUpperCase())
9+
})
10+
.join(' ')
11+
}
12+
13+
console.log(titleCase('I am a coding guru'))
14+
console.log(titleCase('Everyone want to work at Google'))

0 commit comments

Comments
 (0)