Is there any other way to put some arrays together and be able to call only one element of them randomly?
<p>I need to grab the elements of some small arrays and put them together to make a bigger array. But I don't want those small arrays to be the elements of the big array. I just need their elements. Then I need to randomly chose ONLY one element from the big array.
Normally the big array will be:</p>

<pre><code>Array.prototype.randomElement = function () {
return this[Math.floor(Math.random() * this.length)]
}

var small_1_array = [1,2,3,4];
var small_2_array = [5,6,7,8,9];
var small_3_array = [10,11,12];

var big_array = [small_1_array, small_2_array, small_3_array];
console.log("big_array is: " + big_array);
</code></pre>

<p>Result:</p>

<pre><code>big_array is: 1,2,3,4,5,6,7,8,9,10,11,12
</code></pre>

<p>The problem with this way is that I can only choose one of the the small arrays(a group of numbers), but not their elements(only a number). For example:</p>

<pre><code>console.log("a random number from big_array is: " + big_array.randomElement());
</code></pre>

<p>Result:</p>

<pre><code>a random number from big_array is: 1,2,3,4
</code></pre>

<p>And this is a solution I could think of:</p>

<pre><code>var rearrange_array = (big_array.toString()).split(",");
console.log("rearrange_array is : " + rearrange_array);
</code></pre>

<p>Result:</p>

<pre><code>rearrange_array is : 1,2,3,4,5,6,7,8,9,10,11,12
</code></pre>

<p>Now if I execute:</p>

<pre><code>console.log("a random number from rearrange_array is: " + rearrange_array.randomElement());
</code></pre>

<p>the result would be something like this:</p>

<pre><code>a random number from rearrange_array is: 2
</code></pre>

<p>Is there any other way to put some arrays together and be able to call only one element of them?</p>
