Answers for "js operate with currency number"

0

javascript format number as currency

const formatter = new Intl.NumberFormat('en-US', {
  style: 'currency',
  currency: 'USD',
  minimumFractionDigits: 2
})

formatter.format(1000) // "$1,000.00"
formatter.format(10) // "$10.00"
formatter.format(123233000) // "$123,233,000.00"
Posted by: Guest on June-02-2021
0

javascript get currency symbol by currencyCode

var str1 = '10,00 fr';
var str2 = '12.22 $';

function getCurrencySymbol(str) {
  //replace all numbers, spaces, commas, and periods with an empty string
  //we should only be left with the currency symbols
  return str.replace(/[\d\., ]/g, '');
}

console.log(getCurrencySymbol(str1));
console.log(getCurrencySymbol(str2));
Posted by: Guest on December-08-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language