Created
November 16, 2020 18:23
-
-
Save scsskid/968e465959ceb5563a21a7bd5da198a6 to your computer and use it in GitHub Desktop.
[Number Formatter] src: https://developers.shopware.com/blog/2017/02/06/currency-formatting-is-easy-isnt-it/
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
function NumberFormatter(locale, opts) { | |
var formatNumber, | |
defaults = { | |
style: 'currency', | |
currency: 'EUR' | |
}; | |
opts = opts || {}; | |
opts = Object.assign({}, defaults, opts); | |
formatNumber = new Intl.NumberFormat(locale, opts); | |
return formatNumber.format; | |
}; | |
var formatter = new NumberFormatter('de-DE'); | |
console.log(formatter(12.49)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment