Skip to content

Instantly share code, notes, and snippets.

@tigarcia
Created September 1, 2017 00:05
Show Gist options
  • Save tigarcia/673643a0564dc0ef9417690a1f67abbf to your computer and use it in GitHub Desktop.
Save tigarcia/673643a0564dc0ef9417690a1f67abbf to your computer and use it in GitHub Desktop.
function upperCaseFirstLetter(word) {
return word[0].toUpperCase() + word.slice(1);
}
function upperCaseWords(sentence) {
var words = sentence.split(" ");
for (var i = 0; i < words.length; i++) {
words[i] = upperCaseFirstLetter(words[i]);
}
return words.join(" ");
}
console.log(upperCaseWords("code example to refactor"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment