“Формат валюты” Ответ

Формат валюты

/* 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
MONIN

номер формата валюты

// 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
Bored Bird

Ответы похожие на “Формат валюты”

Вопросы похожие на “Формат валюты”

Больше похожих ответов на “Формат валюты” по JavaScript

Смотреть популярные ответы по языку

Смотреть другие языки программирования