Skip to main content

Command Palette

Search for a command to run...

A better way to write large numbers - Daily JavaScript Tips #9

Published
β€’1 min read
A better way to write large numbers - Daily JavaScript Tips #9
D

I am 17 years old and a young passionate and self-taught frontend web developer and have an intention to become a successful developer. I usually write about JavaScript and Web Development and share some tips in the articles.

Hello Folks πŸ‘‹

What's up friends, this is SnowBit here. I am a passionate self-taught young developer having the intention to become a successful developer.

Today, I am here with an amazing topic about numbers πŸ’―

So let's get started πŸš€,

Do you think it is a good idea to write lots of zeros for a billion or trillion?

const billion = 1000000000
const trillion = 1000000000000

And the answer is a big NO! this way is only efficient for hundreds and thousands not for the big number like this. You can write like this but in the end, it becomes tedious and hard to read.

So, I have a proper solution for it and you will be amazed

const billion = 1e9
console.log("Billion " + billion)
const trillion = 1e12
console.log("Trillion " + trillion)

Copy this code and try once!


Thank you for reading, have a nice day! Your appreciation is my motivation 😊

More from this blog

D

Dhairya Shah

119 posts