New to Digit.js?
Check out the getting started guidetoWord(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));
Reserved keywords: toWord, commas
Eventually, I'll dynamically generate the names for the numbers, but for now it's manual.
Thanks for coming :)