[Solved] JS counter with adding spaces


You can just create another helper-function, that takes a number as an input and gives you the localized string back. Then you can wrap the part of your code with it, that gives you the actual number (Math.ceil(now)).
The combination of the two for arabic (just an example) would look like this:

function startCounter(){
    $('.counter').each(function (index) {
        $(this).prop('Counter',0).animate({
        Counter: $(this).text()
        }, {
        duration: 2000,
        easing: 'swing',
        step: function (now) {
            $(this).text(toArabic(Math.ceil(now)));
        }
        });
    });
}   

function toArabic(x) {
    return x.toLocaleString('ar-EG');
}

startCounter();

To get your specific country-code, just look up “BCP 47 language tag”.
Hope I could help 🙂

solved JS counter with adding spaces