Javascript printing from nested arrays
<p>I am currently working on a random number generator script that will generate three numbers.  The first two numbers will be used to pick a "cell" in a "table" by referencing the row and column.  Within each cell are two numbers to choose from.  The third number will then determine which of the two numbers to select.  I have figured out most of this but I am having problems with the last part.</p>

<p>My "solution" was to create twenty arrays, and within each array are twenty more arrays.  Here is an example of the first array:</p>

<p>In the header I have the following:</p>

<p>Scripts to generate the first two numbers:</p>

<pre><code>var randOne20 = Math.floor(Math.random()*20);
var randTwo20 = Math.floor(Math.random()*20);
</code></pre>

<p>Here is the first row of the 20 arrays:</p>

<pre><code>var lvl1Roll1 = [[ 1,0 ],[ 1,1 ],[ 1,2 ],[ 1,3 ],[ 1,4 ],[ 1,5 ],[ 1,6 ],[ 1,7 ],[ 1,8 ],[ 1,9 ],[ 1,10 ],[ 1,11 ],[ 1,12 ],[ 1,13 ],[ 1,14 ],[ 1,15 ],[ 1,16 ],[ 1,17 ],[ 1,18 ],[ 1,19 ]];
</code></pre>

<p>The second row would be "lvl1Roll2" and the third would be "lvl1Roll3" etc. all the way up to "lvl1Roll20."</p>

<p>In the body I have the following script:</p>

<pre><code>var randOne = randOne20 + 1;

document.write(window['lvl1Roll'+randOne][randTwo20]);
</code></pre>

<p>The randOne variable is used to select the appropriate row.  </p>

<p>I can figure out how to select a specific cell (using the randTwo20 variable) but I have no idea how to then select the first or the second number within each cell.</p>

<p>Now, just to clarify, I have not listed the third random number generator code because at the moment I am just trying to figure out how to select either the first or second number within each cell.  Once I figure that out I can just use an if/else statement.</p>

<p>Also, if I did not want to print out the number but select it as a variable how would I do that?</p>

<p>Thank you for any and all help!</p>

<p>Take care and have a great day....</p>

<p>ciao,
john.</p>
