0

I'm using the following JS code for a timer:

jQuery(function($) {
    $('.timer').countTo({
        from: 2046430,
        to: 2048503,
        speed: 3050000,
        refreshInterval: 50,
        onComplete: function(value) {
            console.debug(this);
        }
    });
});

How do I add commas to "2046430" so it looks like "2,046,430"?

Thanks for the help!

  • You have got the answer here :http://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript – Sandeep Nayak Dec 11 '13 at 05:03
  • Are you looking to format the numbers for output, or to format the numbers differently in your code? – jameslafferty Dec 11 '13 at 05:21

1 Answers1

3

simply use java-script method

var num = 2046430; 
num.toLocaleString();

will give you "2,046,430"
A.T.
  • 24,694
  • 8
  • 47
  • 65