I am using react and looking for a module that can convert amounts based on currency symbol? What would be a good module for this?
            Asked
            
        
        
            Active
            
        
            Viewed 31 times
        
    1 Answers
2
            With regard to formatting, take a look at Intl.NumberFormat, see this answer to a previous question.
var number = 123456.789;
console.log(new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(number));
// expected output: "123.456,79 €"
// the Japanese yen doesn't use a minor unit
console.log(new Intl.NumberFormat('ja-JP', { style: 'currency', currency: 'JPY' }).format(number));
// expected output: "¥123,457"
As for calculation; they're just numbers, you can calculate in the regular way.
 
    
    
        Matt
        
- 3,677
- 1
- 14
- 24
- 
                    
- 
                    You'd have to convert your `Big` to a `Number` before formatting it, i.e. `let b = new Big("123.45"); let n = Number(b); Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(n);` – Matt Feb 11 '19 at 04:25
