-1

I've already searched but I haven't found a solution. I have a list products and each product has a different price:

ex1: 53990 ex2: 160115

How can I change these to a currency format? I'm from Brazil so ex1 needs to be: R$ 539,00 and ex2: R$ 1.601,15

I've already tried the code below, but it hasn't worked:

row.price.toFixed(3).replace(/(\d)(?=(\d{3})+\.)/g, '$1,')
RickL
  • 3,318
  • 10
  • 38
  • 39
Cesar Augusto
  • 151
  • 1
  • 9
  • Please use the snippet to create a [mcve] - your description does not make sense and there are thousands of examples how to format money including Indian Lahk etc – mplungjan Mar 28 '18 at 19:12

1 Answers1

-3

My suggestion is to use the accounting library:

var accounting = require('accounting')
accounting.formatMoney(12345.67, {
  symbol: 'R$',
  decimal: ',',
  thousand: '.',
  format: '%s %v',
})
Matheus Portela
  • 2,420
  • 1
  • 21
  • 32