Random floating point double in Inclusive Range

I believe there is much better decision but this one should work 🙂

function randomInRange(min, max) {
  return Math.random() < 0.5 ? ((1-Math.random()) * (max-min) + min) : (Math.random() * (max-min) + min);
}

Leave a Comment