How to make this number "1234567890" into "1,234,567,890"?
So a whole number to separate by commas, so I can format it to look like that? Important thing is for it go from last digit, so in this case "0", and every 3 digt to plant a comma.
2 Replies
You can use toLocaleString on numbers https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString
MDN Web Docs
Number.prototype.toLocaleString() - JavaScript | MDN
The toLocaleString() method of Number values returns a string with a language-sensitive representation of this number. In implementations with Intl.NumberFormat API support, this method simply calls Intl.NumberFormat.
Worked perfectly! Thanks!