SHOW:
|
|
- or go back to the newest paste.
1 | - | function LetterCapitalize(str) { |
1 | + | function LetterCapitalize(str) { // str = "this is test" |
2 | - | return str.split(' ').map(function(word){ |
2 | + | return str.split(' ') // ["this", "is", "test"] |
3 | - | return word[0].toUpperCase() + word.substring(1); |
3 | + | .map(function(word){ |
4 | - | }).join(' '); |
4 | + | return word[0].toUpperCase() + word.substring(1); // ["This", "Is", "Test"] |
5 | }) | |
6 | .join(' '); // "This Is Test" | |
7 | } |