Number separator with commas
separate number with commas
by Osama Qassar
JavaScript
function numberWithCommas(x) {
return x.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");
}
alert(numberWithCommas(12345678))
by Osama Qassar
function numberWithCommas(x) {
return x.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");
}
alert(numberWithCommas(12345678))