How to Format currency using javascript

1) Insert commas between every third digit from right to left for numbers 1000 and greater. It will make numbers easier to read. The number 9,999,999.00 is easy to read as compare to 9999999.00


Input:-
1000.00


Output:-
1,000.00


2) Round numbers to the nearest hundredth, with two digits after the decimal point. It will help you when displaying the total price of the orders.


Input:-
9999.999


Output:-
10,000.00

Let's have a look over the first example that will insert commas between every third digit from right to left for numbers 1000 and greater.

0 comments:

Post a Comment