format rupiah function javascript code example
Example 1: javascript rupiah format
const numb = 1000000;
const format = numb.toString().split('').reverse().join('');
const convert = format.match(/\d{1,3}/g);
const rupiah = 'Rp ' + convert.join('.').split('').reverse().join('')
console.log(rupiah)
Example 2: javascript format rupiah
const formatter = new Intl.NumberFormat('en-ID', {
style: 'currency',
currency: 'IDR'
}).format(10000000)
.replace(/[IDR]/gi, '')
.replace(/(\.+\d{2})/, '')
.trimLeft()
console.log(`Rp ${formatter}`)