main.js
1
2
3
4
5
6
7
8
9
10
11
12
// Generate random number in a range
   function randomGen(min,max) {
      return Math.round(Math.random() * (max - min) + min);
   }
   
   // Function to get random number - not continuous
   function randomPick(arr) {
     return arr[randomGen(arr.length-1,0)];
   }
   
   console.log(randomGen(0,9));
   console.log(randomPick([2,6]));
Native Browser JavaScript