Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const formatAsMoney = (amount, buyerCountry) =>
  2. {
  3. let code = countries[0].code;
  4. let currency = countries[0].currency;
  5. for (let locale of countries){
  6. if(locale.country === buyerCountry)
  7. {
  8. code = locale.code;
  9. currency = locale.currency;
  10. break;
  11. }
  12. }
  13.  
  14. return amount.toLocaleString(`en-${code}`,
  15. {
  16. style:'currency',
  17. currency: currency,
  18. currencyDisplay:'symbol'
  19. }
  20. );
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement