addComma function using recursion


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



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.