SHARE
TWEET

Untitled

a guest Aug 18th, 2019 55 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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top