Format numbers using compact notation
Engineer working in Cerebras. Latest work is Cerebras Inference. I love writing code in React, TypeScript, C++, Python. I spend most of my work hours tinkering with code.
const number = 2500000;
// Basic usage
const formatter = new Intl.NumberFormat('en-US', {
notation: 'compact',
compactDisplay: 'short' // 'short' or 'long'
});
console.log(formatter.format(number)); // "2.5M"
