AS3 Capitalise the First Letter of a String


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. var myString:String = "hello";
  2. trace(myString);
  3. myString = catipaliseFirstLetter(myString);
  4. trace(myString);
  5.  
  6. function catipaliseFirstLetter($s:String):String {
  7. return $s.substring(0, 1).toUpperCase() + $s.substr(1, $s.length-1);
  8. }
  9.  
  10. // OUTPUT
  11. // hello
  12. // Hello

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.