DEV Community

Discussion on: How do you do random?

Collapse
 
krofdrakula profile image
Klemen Slavič

There's a bug in your example; if the output is supposed to be [start, end), then the correct implementation is:

const pseudoRandomInteger = (start, end) =>
  start + Math.floor(Math.random() * (end - start));

✌😉

Collapse
 
joelnet profile image
JavaScript Joel

I probably should have run it once. lol.

I gotta stop typing code directly into editors.

Good catch!