Good day, suppose I have the following example number:
var numero=12457.13
I want to be able to format that number, to get it separated by commas, the result would be like this:
12,457.13
Reading I saw that it should be achieved using the toLocaleString()
javascript method, but it didn't work for me. Any ideas? Thanks in advance
I don't know why the function wouldn't work for you
toLocaleString()
, but you were looking in the right place. I leave you an example of use with your case:Use this code: