Skip to content

Instantly share code, notes, and snippets.

@NEbere NEbere/title_case.js
Created Feb 11, 2016

What would you like to do?
Return the provided string with the first letter of each word capitalized.
function titleCase(str) {
var strArray = str.toLowerCase().split(' ');
for (var i = 0; i < strArray.length; i++) {
strArray[i] = strArray[i][0].toUpperCase() + strArray[i].slice(1);
return strArray.join(' ');
titleCase("I'm a little tea pot");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.