customize digital number formatter javascript code example
Example 1: js format urcurency
// Create our number formatter.
var formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
});
formatter.format(2500); /* $2,500.00 */
Example 2: javascript currency format
const formatter = new Intl.NumberFormat('en-ID', {
style: 'currency',
currency: 'IDR'
}).format(10000000)
.replace(/[IDR]/gi, '')
.replace(/(\.+\d{2})/, '')
.trimLeft()
console.log(`Rp ${formatter}`)