Getting Started

Paste this into your head tag...

<!-- Hamza Nasher-Alneam's Digit.js library -->
<script src="https://hnasheralneam.github.io/digit/main.js">

... And you're ready to go!



Test it!

Let's start with a large number. How about 1000000000000? Try sending that to the console.

console.log(1000000000000);

That should return this:

1000000000000

That's impossible to read! Try adding commas to it with the commas function.

1,000,000,000,000

That's much better! But what if we wanted to make it even more readable? We could use the toWord function, like so:

toWord(1000000000000);

And that should return...

"1.0 Trillion"

Awesome! But let's say we're a little short for space. We can use the type parameter to shorten the word.

toWord(1000000000000, "short");

Which returns...

"1.0 t"

And that's it! Simple, right? And you're ready to start using digit.js!

If you want to learn more, check out the docs ->