Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Luke-Rogerson/125108eae3fc7d950f8efae507896c3e to your computer and use it in GitHub Desktop.
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
/*
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