Posted By

garamond on 10/26/06


Tagged

number


Versions (?)

addComma function using recursion


 / Published in: ActionScript
 

  1. function addComma(num:Number):String {
  2. var tmp = num.toString();
  3. if(tmp.length > 3) {
  4. return arguments.callee(tmp.substring(0, tmp.length - 3)) +
  5. "," +
  6. tmp.substring(tmp.length - 3, tmp.length);
  7. } else {
  8. return tmp;
  9. }
  10. }

Report this snippet  

You need to login to post a comment.