Is there a simple way to convert a string to title case? E.g. john smith becomes John Smith. I\'m not looking for something complicated like John R
john smith
John Smith
If regex used in the above solutions is getting you confused, try this code:
function titleCase(str) { return str.split(' ').map(function(val){ return val.charAt(0).toUpperCase() + val.substr(1).toLowerCase(); }).join(' '); }