get currency javascript code example
Example 1: javascript get currency symbol by currencyCode
var str1 = '10,00 fr';
var str2 = '12.22 $';
function getCurrencySymbol(str) {
return str.replace(/[\d\., ]/g, '');
}
console.log(getCurrencySymbol(str1));
console.log(getCurrencySymbol(str2));
Example 2: javascript get currency symbol by currencyCode
var str1 = '10,00 €';
var str2 = '12.22 $';
function getCurrencySymbol(str) {
return str.replace(/[\d\., ]/g, '');
}
console.log(getCurrencySymbol(str1));
console.log(getCurrencySymbol(str2));