Skip to main content

shortenNumber

Shortens a given number to its shortest form so it can occupy little space as possible.

API

function shortenNumber(number: number, isToRoundNumber?: boolean): (string | number)[];

Usage

import { shortenNumber } from '@feedzai/js-utilities';

shortenNumber(10000)
// [10,"K"]

shortenNumber(10250)
// [10.2, "K"]

shortenNumber(1000000)
// [1, "M"]

shortenNumber(1300000)
// [1.3, "M"]