JSFiddle - React, Tailwind, and code Playground
by cancerbero_sgx
JavaScript
function formatCurrency(amount)
{
'use strict';
var shopper_currency = session.getShopperCurrency()
, formatted_amount = parseFloat(amount);
formatted_amount = isNaN(formatted_amount) ? 0 : formatted_amount;
return (formatted_amount < 0 ? '-' : '') + shopper_currency.symbol + Math.abs(formatted_amount).toFixed(shopper_currency.precision);
}
function toCurrency(amount)
{
'use strict';
var r = parseFloat(amount);
return isNaN(r) ? 0 : r;
}
var str = "$1,999,999.00";
var s2 = str.replace( /^\D+/g, '');
alert(s2);