“JavaScript Get Currency Symbol by CurrencyCode” Respostas de código

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));
Outrageous Opossum

JavaScript Get Currency Symbol by CurrencyCode

var str1 = '10,00 €';
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));
Outrageous Opossum

Respostas semelhantes a “JavaScript Get Currency Symbol by CurrencyCode”

Perguntas semelhantes a “JavaScript Get Currency Symbol by CurrencyCode”

Mais respostas relacionadas para “JavaScript Get Currency Symbol by CurrencyCode” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código