Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

currency format

/* https://www.npmjs.com/package/format-money-js */

const { FormatMoney } = require('format-money-js');

const fm = new FormatMoney({
  decimals: 2
});

console.log(fm.from(12345.67, { symbol: '$' })); // return string: $12,345.67
console.log(fm.un('€12,345;67')); // return number: 12345.67
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript determine if string is valid url 
Javascript :: datetime to date javascript 
Javascript :: dynamic loop variable .each create hash javascript 
Javascript :: input radio trigger select jquery 
Javascript :: javascript canvas beziercurveto 
Javascript :: javascript round to 8 decimal places 
Javascript :: nodejs buffer.from base64 
Javascript :: How to use body-parser package in using npm 
Javascript :: dataset js 
Javascript :: json vs gson 
Javascript :: js reverse JSON.stringify 
Javascript :: firebase where or 
Javascript :: javascript split string into array by comma 
Javascript :: click events javascript 
Javascript :: javascript get all methods of class 
Javascript :: javascript tick marks 
Javascript :: javascript foreach example 
Javascript :: active js 
Javascript :: export all functions from js file 
Javascript :: generate random string react 
Javascript :: count the number of elements in an array javascript 
Javascript :: unwind check after null or undefined 
Javascript :: javascript append child 
Javascript :: jqery get text 
Javascript :: get bottom position of element javascript 
Javascript :: jest mock createobjecturl 
Javascript :: javascript type casting int 
Javascript :: localstorage set 
Javascript :: react prevent component from update once mounted 
Javascript :: html set textarea value 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =