0

Hi I wanna get random numbers out of 2,3,5 . So i use this code.

function Random(low, hi) {
     return Math.floor(Math.random() * (hi - low + 1) + low);
 }

But this is only for 2 numbers , But i wanna get for 1 time for example 3 for 2 time 5, and 3 time 3 , but of course not exactly in that order . Any ideas ?

Tiko
  • 1,241
  • 11
  • 19

1 Answers1

2
function random(numbers) {
     return numbers[Math.floor(Math.random()*numbers.length)];
}

Then you can call it with a list:

random([2, 3, 5])
lopoto
  • 231
  • 1
  • 8