var computeST = 2145523 var resultFormat= <-- format the computeST here --> alert(resultFormat);
the display alert should be
2,145,523
Anyone can help me?
Advertisement
Answer
Try this:
console.log(numberWithCommas(2145523)); function numberWithCommas(x) { return x.toString().replace(/B(?=(d{3})+(?!d))/g, ","); }