javascript format currency
function formatToCurrency(amount){
return (amount).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
formatToCurrency(12.34546); //"12.35"
formatToCurrency(42345255.356); //"42,345,255.36"
javascript format currency
function formatToCurrency(amount){
return (amount).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
formatToCurrency(12.34546); //"12.35"
formatToCurrency(42345255.356); //"42,345,255.36"
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));
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us