Skip to main content

abbrev

The abbrev() function abbreviates a large number with a letter suffix.

Parameters

ParameterTypeDescription
numNumberThe number to abbreviate.

Returns

  • String: The abbreviated string

Examples

const utils = require('utils-core.js');
const num = 1500;
const abbreviatedNum = utils.format.abbrev(num);
console.log(abbreviatedNum);
// output: "1.5K"
const utils = require('utils-core.js');
const num = "987654321";
const abbreviatedNum = utils.format.abbrev(num);
console.log(abbreviatedNum);
// output: "988M"
const utils = require('utils-core.js');
const num = "2500000000";
const abbreviatedNum = utils.format.abbrev(num);
console.log(abbreviatedNum);
// output: "2.5b"