Preview:
export function convertToBMK(input) {
  return Math.abs(Number(input)) >= 1.0e9
    ? (Math.abs(Number(input)) / 1.0e9).toFixed(2) + " B"
    : Math.abs(Number(input)) >= 1.0e6
    ? (Math.abs(Number(input)) / 1.0e6).toFixed(2) + " M"
    : Math.abs(Number(input)) >= 1.0e3
    ? (Math.abs(Number(input)) / 1.0e3).toFixed(2) + " K"
    : Math.abs(Number(input));
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter