Skip to content

Commit 5dfc684

Browse files
author
Coding Money
committed
title case solution
1 parent 513c4f1 commit 5dfc684

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: completed_exercises/5-titlecase.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
// capitalize('what is titlecase?') --> 'What Is Titlecase?'
88
// capitalize('titles of books, movies, songs, plays and other works') --> 'Titles Of Books, Movies, Songs, Plays And Other Works'
99

10-
function capitalize(str) {}
10+
function capitalize(str) {
11+
const words = str.split(' ')
12+
//['this', 'is', 'mukhtar'..]
13+
14+
15+
return words.map(word => word[0].toUpperCase() + word.slice(1)).join(' ')
16+
17+
}
1118

1219

1320
console.log(capitalize('this is mukhtar from coding money'));

0 commit comments

Comments
 (0)