Skip to content

Instantly share code, notes, and snippets.

@isacjunior
Last active October 20, 2017 16:39
Show Gist options
  • Save isacjunior/48c3f50dcd64d4e865b98f961b4f401d to your computer and use it in GitHub Desktop.
Save isacjunior/48c3f50dcd64d4e865b98f961b4f401d to your computer and use it in GitHub Desktop.
const sales = [
{ name: 'João', amount: 11792.23, currency: 'BRL', country: 'Brazil', language: 'pt-BR' },
{ name: 'Manoel', amount: 3899.05, currency: 'EUR', country: 'Portugal', language: 'pt-PT' },
{ name: 'José', amount: 259, currency: "USD", country: 'United States', language: 'en-US' }
]
const formatCurrency = ({ amount, language, currency }) => {
return {
amountFormatted: amount.toLocaleString(language, { style: 'currency', currency: currency })
}
}
const amountWithCurrency = sales.map(formatCurrency)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment