How would I modify the following to include commas in the output? For example output of 300000 would print as `300,000'?
the html
<span class="number counter" data-count="300000">300,000</span>
the magic:
jQuery(document).ready(function($) {
    $('.counter').each(function() {
        var $this = $(this),
            countTo = $this.attr('data-count');
        $({countNum: $this.text()}).animate({
                countNum: countTo
            },
            {
                duration: 999,
                easing:'linear',
                step: function() {
                    $this.text(Math.floor(this.countNum));
                },
                complete: function() {
                    $this.text(addCommas(this.countNum));
                    console.log('finished')
                }
            });
        function addCommas(nStr){
            //return comma
        }
    });
});
This is different from - How do I format numbers using JavaScript? - because I need to countup and display counter with comma - the action during step is what requires dynamic comma being added.
 
    