1function numberWithCommas(x) {
2 return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
3}
1function formatMoney(n) {
2 return "$ " + (Math.round(n * 100) / 100).toLocaleString();
3}
4
5n = 2123000;
6// =>2,123,000
1function numberWithCommas(x) {
2 return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
3}
4