Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

number format currency

// Create our number formatter currency 
var formatter = new Intl.NumberFormat('en-US', {
  style: 'currency',
  currency: 'USD',

  // These options are needed to round to whole numbers if that's what you want.
  //minimumFractionDigits: 0, // (this suffices for whole numbers, but will print 2500.10 as $2,500.1)
  //maximumFractionDigits: 0, // (causes 2500.99 to be printed as $2,501)
});

formatter.format(2500); /* $2,500.00 */

// my code
'Rp. '+ new Intl.NumberFormat().format(2500) // Rp. 2,500
 
PREVIOUS NEXT
Tagged: #number #format #currency
ADD COMMENT
Topic
Name
8+4 =