Comma delimiter for numbers in thousands

PHOTO EMBED

Thu Feb 17 2022 05:54:17 GMT+0000 (Coordinated Universal Time)

Saved by @karthikbt22 #undefined #javascript

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

https://jsbin.com/