0

I have what I thought was a simple Javascript formula:

parseInt(Math.ceil(Math.random() * 1000000).toString() + Date.now())

which I would expect to give me a number that is simply a random number concatenated (not added) with a timestamp.

When I look at just part of the code: Math.ceil(Math.random() * 1000000).toString() + Date.now() this does give me the string I would expect, such as "9220291542844303075".

However, when I try converting this string into a number using parseInt() or Number(), those methods both return the desired number with three zeros at the end of it, such as: 9220291542844303075000

How can I get the actual String I have converted to its same number so that "9220291542844303075" becomes 9220291542844303075 without the extra zeros, and why is the way I am doing it not working?

Bryan Miller
  • 3,262
  • 4
  • 27
  • 51

0 Answers0