Capitalize First Letter in each word - Javascript

function capFirst(string){ var newString = ''; string = string.toLowerCase(); strings = string.split(' '); for(var i = 0; i < strings.length; i++){ newString = newString + ' ' + strings[i].charAt(0).toUpperCase() + strings[i].slice(1); } return newString; }

1 Response

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.