andru26
9/30/2017 - 7:36 PM

Number with commas. eg: 1,000,000

Number with commas. eg: 1,000,000

function numberWithCommas(x) {

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

}