|
String.prototype.capatilize = function(_type){ // type 1 capatilizes first word. type 2 capatilizes all var _type = (_type?_type:1); switch(_type.toString()){ case "1": return this.substring(0,1).toUpperCase()+this.substring(1); break; case "2": var data = ""; var si = this.split(/\s/); while(si[0]){ data += si[0].substring(0,1).toUpperCase()+si[0].substring(1)+" "; si.splice(0,1); } return data; } }
There's actually two types in this. Type "1" capatilizes the first word of the string. Type "2" capatilizes every word in the string. I'm thinking about adding a type "3" which would capatilize the first word in a sentence.
|
|
|
|
|
I've noticed a lot of your variables start with _ lately, what's with that
|
|
|
|
I'm starting to do that too actually. Reason being I find the gImage and all a little tacky and writing plain Image or whatever can be interpreted as something I didn't intend. In truth it just looks cleaner as the variables blend right in with the script.
Last Edit: Jul 20, 2006 2:07:00 GMT by Aaron
|
|
|
|
I mainly do it for variables inside of functions. IT makes them more.... unique.
|
|
|
|