use .toLocaleString() you will find more about it on w3 schools but it is quite efficient when you want to do number formatting you can use us for seamless conversion ....however regexp is also a good approach here you can read about it