Generate compact number in Javascript ES6

2 years 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 codes

view all

Latest Snippets

view all