'Where to put the .join in this function in order to rejoin the separated strings of an array
Problem to solve is to capitlize the first letter of each word in a string using '.split' '.map' and 'join'. Currently implemented split and map to get the word capitlised and rejoined it, but confused as to where I need to put the .join.
Expected: "The Lord Of The Rings"
Received: ["The", "Lord", "Of", "The", "Rings"]
function titleCase(string) {
return string.split(' ').map(word => word.charAt(0).toUpperCase() + word.substr(1))
}
Solution 1:[1]
First: split the string
Second: Capitalize word
Third: Join words
return string.split(' ').map(word => word.charAt(0).toUpperCase() + word.substr(1)).join(' ');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Pipe |
