formatting - How to print a number with commas as thousands separators in JavaScript - Stack Overflow

PHOTO EMBED

Tue Aug 18 2020 15:41:54 GMT+0000 (Coordinated Universal Time)

Saved by @rdemo #javascript

function numberWithCommas(x) {
    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
content_copyCOPY

https://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript