user12742603
user12742603

Reputation:

Intl.NumberFormat String Currency before number

The following string return the value like: 938.173,00 euro. How to obtain the value like: Euro 938.173,00?

formattedValue = value.toLocaleString('it-IT', {currency: 'EUR', currencyDisplay: 'name', style: 'currency'});

Thanks

Upvotes: 0

Views: 561

Answers (1)

TheMaster
TheMaster

Reputation: 50565

There doesn't seem to be any specific options in Intl to custom-prepend the currency. It is done automatically according to your locale. But, you could simply String.replace:

const value = 938173.00
const formattedValue = `euro ${value.toLocaleString('it-IT', {currency: 'EUR', currencyDisplay: 'name', style: 'currency'}).replace(" euro","")}`;
console.info(formattedValue);

Upvotes: 1

Related Questions