jquery thousand separator

Solutions on MaxInterview for jquery thousand separator by the best coders in the world

showing results for - "jquery thousand separator"
Veronica
06 Aug 2019
1function addCommas(nStr) {
2    nStr += '';
3    var x = nStr.split('.');
4    var x1 = x[0];
5    var x2 = x.length > 1 ? '.' + x[1] : '';
6    var rgx = /(\d+)(\d{3})/;
7    while (rgx.test(x1)) {
8        x1 = x1.replace(rgx, '$1' + ',' + '$2');
9    }
10    return x1 + x2;
11}