Skip to content

Instantly share code, notes, and snippets.

@AviTapp
Last active December 26, 2017 19:00
Show Gist options
  • Save AviTapp/9c9dd2a9ff13a00ed03b980f3a8e40b8 to your computer and use it in GitHub Desktop.
Save AviTapp/9c9dd2a9ff13a00ed03b980f3a8e40b8 to your computer and use it in GitHub Desktop.
Return the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case.
function titleCase(t) {
for (t = t.toLowerCase().split(" "), i = 0; i < t.length; i++) t[i] = t[i].split(""), t[i][0] = t[i][0].toUpperCase(), t[i] = t[i].join("");
return t = t.join(" ")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment