Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
56
rated 0 times [  62] [ 6]  / answers: 1 / hits: 10696  / 10 Years ago, wed, may 14, 2014, 12:00:00
var computeST = 2145523
var resultFormat= <-- format the computeST here -->
alert(resultFormat);


the display alert should be




2,145,523




Anyone can help me?


More From » javascript

 Answers
3

Try this:





console.log(numberWithCommas(2145523));

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




[#45322] Tuesday, May 13, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
keana

Total Points: 452
Total Questions: 97
Total Answers: 81

Location: Barbados
Member since Sun, Nov 27, 2022
1 Year ago
;