decimal currency format code example
Example: format currency amount from number to decimal as currency
function formatCurrency(currencySymbol: any, decimalSeparator: any) {
return function (value: any) {
const wholePart = Math.trunc(value / 100);
let fractionalPart = value % 100;
if (fractionalPart < 10) {
fractionalPart = 0 + fractionalPart;
}
return `${currencySymbol}${wholePart}${decimalSeparator}${fractionalPart}`;
};
}
const PriceLabel = formatPrice('£', '.');
console.log(PriceLabel(53296))