0

As an example I would like to get values between 32.2000 and 32.2999

I assume it would be something similar to

(Math.random() + 32.2).toFixed(4)

but it seems to generate any value between 32.xxxx and 33.xxxx

Am I making an obvious error on my end or is it more complex than I initially assumed?

ekjcfn3902039
  • 1,673
  • 3
  • 29
  • 54
  • This is not a duplicate as it is a particular range starting with a static number before the decimal – ekjcfn3902039 Feb 15 '19 at 14:48
  • 2
    Yes it is. `console.log( (Math.random() * (32.2999 - 32.2000) + 32.2000).toFixed(4) )` – mplungjan Feb 15 '19 at 14:49
  • 1
    Sigh, thought I tried that at one point but I accidentally put a plus instead of a times after Math.random, which is what threw me off. Got it now, thanks! – ekjcfn3902039 Feb 15 '19 at 14:53

0 Answers0