“JavaScript erhalten Währungssymbol von CurrencyCode” Code-Antworten

JavaScript erhalten Währungssymbol von 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 erhalten Währungssymbol von 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

Ähnliche Antworten wie “JavaScript erhalten Währungssymbol von CurrencyCode”

Fragen ähnlich wie “JavaScript erhalten Währungssymbol von CurrencyCode”

Weitere verwandte Antworten zu “JavaScript erhalten Währungssymbol von CurrencyCode” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen