YulongW
11/6/2014 - 7:59 PM

Number to currency format and currency to number for calculation. (Thanks to stackoverflow)

Number to currency format and currency to number for calculation. (Thanks to stackoverflow)

function currencyToNumber(currency) {
  return Number(currency.replace(/[^0-9\.]+/g,""));
}

function numberToCurrency(number) {
  return "$" + number.toFixed(2).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
}