JSFiddle - React, Tailwind, and code Playground

JavaScript

function farsi(x) {
    x = x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
    alert(x);
    var a = '۰۱۲۳۴۵۶۷۸۹'; var b = ''; 
    for (var i = 0; i < x.length; i++) { 
        var c = x.charCodeAt(i); 
        b += (c >= 48 && c <= 57 ) ? a.charAt(c - 48) : x.charAt(i);
     }
     return b;
 }
 
 
 alert(farsi(33000));