forked from jimmyislive/coderbyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathletter_capitalize.js
More file actions
24 lines (16 loc) · 842 Bytes
/
Copy pathletter_capitalize.js
File metadata and controls
24 lines (16 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
Have the function LetterCapitalize(str) take the str parameter being passed and capitalize the first letter of each word. Words will be separated by only one space. Use the Parameter Testing feature in the box below to test your code with different arguments. Do not modify the function name within the code. Do not put any code outside of the function and use the return keyword to return your answer from within the function.
*/
function LetterCapitalize(str) {
var words = str.split(' ');
var new_str = '';
var letters;
for (var i =0; i < words.length; i++) {
letters = words[i].split('');
new_str += letters[0].toUpperCase() + letters.join('').substring(1) + ' ';
}
return new_str;
}
// this call is needed to test your function
// keep this when you submit your code
LetterCapitalize(str)