1formatPrice(value) {
2 let val = (value / 1).toFixed(2).replace('.', ',')
3 return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".")
4 }
1// Create our number formatter.
2var formatter = new Intl.NumberFormat('en-US', {
3 style: 'currency',
4 currency: 'USD',
5});
6
7formatter.format(2500); /* $2,500.00 */
1// Javascript has a number formatter (part of the Internationalization API).
2
3const number = 123456.789;
4
5// another example
6console.log(new Intl.NumberFormat('ja-JP', {
7 style: 'currency',
8 currency: 'BWP',
9}).format(number));
10
11// MORE INFO -> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat
12
13
1function floatToEuro(float){
2 var euroCurrency
3 euroCurrency = '\u20AC' + float.toLocaleString('nl-NL',{minimumFractionDigits: 2});
4 console.log(euroCurrency);
5 return euroCurrency;
6};