0

So basically i got this function

Math.random()

we were taught to use this formula in order to get values from 1 to x

parseInt(Math.random()*x)+1;

but now what i want to do is to get values from x to y but i'm not sure how to do it .. any help ?

1 Answers1

0

const doRandom = (min,max) => {
return Math.floor(Math.random() * (max - min) + min);
}

console.log(doRandom(5,9));
Joshua Craven
  • 4,407
  • 1
  • 31
  • 39