Skip to content

Instantly share code, notes, and snippets.

@kironroy
Created July 8, 2023 02:30
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 kironroy/6e4597de4273f85c5db72be1730f6e99 to your computer and use it in GitHub Desktop.
Save kironroy/6e4597de4273f85c5db72be1730f6e99 to your computer and use it in GitHub Desktop.
internationalizing numbers
const options2 = {
// style: 'unit',
style: 'currency',
// unit: 'mile-per-hour',
unit: 'celsius',
currency: 'EUR',
// useGrouping: false,
};
const num2 = 3885673.23;
console.log('US: ', new Intl.NumberFormat('en-US', options2).format(num2));
console.log('Germany:', new Intl.NumberFormat('de-DE', options2).format(num2));
console.log('Syria:', new Intl.NumberFormat('ar-SY', options2).format(num2));
console.log(
'Browser:',
new Intl.NumberFormat(navigator.language, options2).format(num2)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment