Just how random is JavaScript Math.random()?

This is just a quick experiment to test if Math.random() implemented in Node.js/V8 is actually as random as it should be. The following code is used to "roll a dice" a hundred thousand times per second. The results can be observed in the table below.

Math.floor(Math.random() * 6) + 1

Using Node.js 22.14.0 with version 12.4.254.21-node.22 of V8 JavaScript engine. (Running on Linux 6.14.2)

Interesting fact: Currently, the longest observed streak of subsequent rolls of six this application has seen is 16. The theoretical probability of that happening is 1 out of 2,821,109,907,456. The theoretical probability of 17 subsequent rolls of six is 1 out of 16,926,659,444,736. That is yet to be observed by this application.

Results of 2,628,964,859,577 "dice throws" using JavaScript Math.random()
Result Number of occurrences % (Should be around 16.67%)
1 438,161,000,025 16.67%
2 438,161,419,950 16.67%
3 438,160,563,942 16.67%
4 438,161,122,931 16.67%
5 438,160,476,066 16.67%
6 438,160,276,663 16.67%
Total 2,628,964,859,577 100 %