Capitalize first letter of a word JS & AS3 (quick tip)

After 10′ of searching for a fast solution I came up with this, I suspect there is a much cooler way of capitalizing with AS3, but if I can’t find it on 2 pages of search results it pretty much doesn’t exist…
So here we go, this might work only for single words but that was the intention.

function capWord(source) {
var cap = String(source).substr(0,1);
cap = String(cap).toUpperCase()+String(source).slice(1);
trace('A capitalized '+cap); // A capitalized Word
window.console.log('A capitalized '+cap);
}

enjoy!

Tagged , , , , , . Bookmark the permalink.

2 Responses to Capitalize first letter of a word JS & AS3 (quick tip)

  1. Chris says:

    Where does item come from?

  2. Fixed it , it is actually the original text. Thanks for noticing!

Leave a Reply

Your email address will not be published. Required fields are marked *