summaryrefslogtreecommitdiffstats
path: root/sick-fits/frontend/lib/formatMoney.js
blob: c001aeed2c6ba65992001779ec2baf9068d410d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
export default function(amount) {
  const options = {
    style: 'currency',
    currency: 'USD',
    minimumFractionDigits: 2,
  };
  // if its a whole, dollar amount, leave off the .00
  if (amount % 100 === 0) options.minimumFractionDigits = 0;
  const formatter = new Intl.NumberFormat('en-US', options);
  return formatter.format(amount / 100);
}