Skip to content

Instantly share code, notes, and snippets.

@sixty4bit
Created August 23, 2009 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sixty4bit/173479 to your computer and use it in GitHub Desktop.
Save sixty4bit/173479 to your computer and use it in GitHub Desktop.
<script type="text/javascript">
function comma(num) {
var collector = new Array();
var numberArray = ('' + num).split('').reverse();
for(var i = 0; i < numberArray.length; i++) {
if(i % 3 == 0 && i != 0) collector.push(",");
collector.push(numberArray[i]);
}
return collector.reverse().join('');
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment