I have a counter that increments every x seconds, here's my code:
var counter=22000000000;
if(typeof(localStorage.getItem('counts'))!='object') {
counter=parseInt(localStorage.getItem('counts'));
}
$(".count").html(counter);
setInterval(function () {
$(".count").html(counter);
++counter;
localStorage.setItem('counts',counter);
}, 18000);
Because the starting number is so high it doesn't read well, see it here: http://jsfiddle.net/vpju4cpr/1/
Ideally instead of outputting 22000000000
I'd like it to read 22,000,000,000
How can I do this?
in your .html() function, change
counter
tocounter.toLocaleString()
like this: