I have requirement to split huge numbers in a format separated by commas
but at the last 3 character i want to put comma before . for e.g 426,753,890
for such i want to put like 42,67,53,890
function numberWithCommas(x) {
var parts = x.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return parts.join(".");
}
console.log(numberWithCommas(426753890));