Skip to content

Instantly share code, notes, and snippets.

@wesleybliss
Created December 17, 2020 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wesleybliss/435b8860671e262dd360709ff67de0a8 to your computer and use it in GitHub Desktop.
Save wesleybliss/435b8860671e262dd360709ff67de0a8 to your computer and use it in GitHub Desktop.
Format currency #js
export const formatCurrency = (number, currency) => {
const options = {
minimumFractionDigits: 2,
currencyDisplay: 'narrowSymbol',
currencySign: 'accounting',
}
if (currency) {
options.style = 'currency'
options.currency = currency
}
return new Intl.NumberFormat(getLocale(), options).format(number)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment