How to format currency by country/language in JavaScript

3 Answers

0 votes
const formatter = new Intl.NumberFormat('en-US', {
  style: 'currency',
  currency: 'USD',
  minimumFractionDigits: 2
});
console.log(formatter.format(100)); 
console.log(formatter.format(7)); 
console.log(formatter.format(98372913));



/*
run:
  
$100.00 
$7.00 
$98,372,913.00
​   
*/

 



answered Nov 8, 2019 by avibootz
0 votes
const formatter = new Intl.NumberFormat('de-DE', {
  style: 'currency',
  currency: 'EUR',
  minimumFractionDigits: 2
});
console.log(formatter.format(100)); 
console.log(formatter.format(7)); 
console.log(formatter.format(98372913));



/*
run:
  
100,00 € 
7,00 € 
98.372.913,00 €
​   
*/

 



answered Nov 8, 2019 by avibootz
0 votes
const formatter = new Intl.NumberFormat('ja-JP', {
  style: 'currency',
  currency: 'JPY',
  minimumFractionDigits: 2
});
console.log(formatter.format(100)); 
console.log(formatter.format(7)); 
console.log(formatter.format(98372913));



/*
run:
  
¥100.00 
¥7.00
¥98,372,913.00
​   
*/

 



answered Nov 8, 2019 by avibootz

Related questions

1 answer 175 views
2 answers 234 views
3 answers 215 views
215 views asked Jan 5, 2023 by avibootz
1 answer 229 views
1 answer 243 views
...