New to Digit.js?

Check out the getting started guide

Functions


toWord(number, type)

Takes in numbers and returns with commas or in word format.

It can take numbers up to Quattuorvigintillion, after which it's just return it with commas.

Numbers under seven charecters will be returned with commas, but without other formatting.


The toWord function takes in two parameters, number and type.

number takes in a number value

type takes one value, "short", which will return short numbers, like t instead of trillion. Leave it empty for long numbers.


Usage

// Returns "1 B"
console.log(toWord(1000000000, "short"));

commas(number)

The commas function will put commas into any number.


Usage

// Returns "1,000,000,000"
console.log(commas(1000000000));


Library reserved words

Reserved keywords: toWord, commas



Notes?

Eventually, I'll dynamically generate the names for the numbers, but for now it's manual.

Thanks for coming :)