Created
November 22, 2017 10:36
-
-
Save kastigar/129f86c8ffe0f45f4ec9060f596b2c67 to your computer and use it in GitHub Desktop.
formatPrice.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const currencySigns = { | |
'USD': '$', | |
'EUR': '€', | |
}; | |
function formatPrice({ price, currency_code}) { | |
const sign = currencySigns[currency_code]; | |
return sign ? `${sign}${price}` : `${price} ${currency_code}`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment