DEV Community

Discussion on: 3 Amazing ways to generate random numbers without Math.random()

Collapse
 
amatiasq profile image
A. Matías Quezada

Middle square method without string manipulation:

function myRandom() {
  seed = Math.floor(((seed ** 2) % 1000) / 10);
  return seed;
}
Collapse
 
svijaykoushik profile image
Vijay Koushik, S. 👨🏽‍💻

Wow! Great work 👍👏👏👏! Why didn't I think of this? 😁