Answers for "format currency amount from number to decimal as currency"

0

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))
Posted by: Guest on October-01-2020

Code answers related to "format currency amount from number to decimal as currency"

Browse Popular Code Answers by Language