Created
May 1, 2018 05:48
-
-
Save Luke-Rogerson/125108eae3fc7d950f8efae507896c3e to your computer and use it in GitHub Desktop.
LetterCapitalize algorithm challenge created by Luke_Rogerson - https://repl.it/@Luke_Rogerson/LetterCapitalize-algorithm-challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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. | |
*/ | |
function LetterCapitalize (str) { | |
let wordArray = str.split(" "); | |
capitalize = function (word) { | |
return word.charAt(0).toUpperCase() + word.slice(1); | |
} | |
let capitalizedArray = wordArray.map(capitalize); | |
return capitalizedArray.join(" "); | |
} | |
LetterCapitalize("i ran there") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment