30 seconds of code

  Back to Home

toCurrency

utilityintermediate

Take a number and return specified currency formatting.

Use Intl.NumberFormat to enable country / currency sensitive formatting.

const toCurrency = (n, curr, LanguageFormat = undefined) =>
  Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n);