I'm wondering if there is a way to make large numbers readable in JavaScript. I'm sure there is I just can't find it. For example, if I am writing
for (var i=0; i < 1000000; i++){
codecodecode};
is there a way to write that 1000000 so that it's readable without disrupting the for loop?
Furthermore, is there a way of returning a large number so that, too, is readable?
Sorry if I explained this poorly, I'm just starting out...
Thanks in advance!
100_000_000_000
const loopCount = 50_000
for (var i=0; i < 1_000_000; i++){
codecodecode};
for more information go here (https://2ality.com/2018/02/numeric-separators.html)
If you are thinking about the source code, you can write 1E6. You are looking for some symbol to seperate the thousands, but unfortunately there is no way.
If you want to convert a number to a more readable string, then this SO post may help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With