1function numberWithCommas(x) {
2 return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
3}
1var number = 3500;
2
3console.log(new Intl.NumberFormat().format(number));
4// → '3,500' if in US English locale
5
1foramtNumber = (num,div=",")=>{
2 return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, div);
3
4}
1function numberWithCommas(x) {
2 return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
3}
4