Generate compact number in Javascript ES6

17 days ago23k times
const formatter = Intl.NumberFormat('en', {
notation:'compact'
});
const numberk = formatter.format(1295); // 1.3K
const number2 = formatter.format(1295000); // 1.3M
const numberk3 = formatter.format(12950); // 13K
const numberk4 = formatter.format(1295324423); // 1.3B

Add Answer

Add a codeAdd Code
Remove adsremove

Latest Snippets

view all