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 :: jest test navlink 
Javascript :: date javascript 
Javascript :: horizontal scrollview in react js 
Javascript :: javascript regex match sequence 
Javascript :: remove duplicate array 
Javascript :: networkx get nodes 
Javascript :: headless ui modal 
Javascript :: switch window 
Javascript :: moment duratuion from hours 
Javascript :: react testing library 
Javascript :: count length of a string javascript 
Javascript :: angular input date pattern validation 
Javascript :: prisma bigint 
Javascript :: html call variable javascript 
Javascript :: pass text and variable in alert javascript 
Javascript :: return object from map javascript 
Javascript :: settings.json in vscode 
Javascript :: node http2 post 
Javascript :: Expresion regular para validar Dirección URL 
Javascript :: apply() js 
Javascript :: what is closure in javascript 
Javascript :: pwa cache viewer 
Javascript :: vadd vue router 
Javascript :: let a = {y;10}; 
Javascript :: filter in javascipt 
Javascript :: reactjs .net pass value to react 
Javascript :: browser support 
Javascript :: js variables 
Javascript :: array.findindex is not a function 
Javascript :: option component in react js errors 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =