A simple way to format currency! Given a number, format it to a currency-esque format.
number.toFixed(decimalPlaces).replace(/(\d)(?=(\d{3})+\.)/g, "$1,");
Sample:
Symbol (EG: R, $):
Number (EG: 1234567.50):
Decimal Places (EG: 1, 2, 3 - Probably 2):
lol
ReplyDelete