Javascript Weighted Probability Array
<p>I'm working on a very basic game which runs in the browser. When the document is ready, I have created some Javascript which displays a random couple of links from a larger link list (both lists are stored in Arrays). My question has two parts - one simple, one complex:</p>

<p>1) Is there a way to make this code more elegant - the function within the array within the array is very ugly...</p>

<p>2) Is there a way to allocate probabilities to the items so that some are more likely to appear than others? At the moment it is just random, with any "button" as likely to appear as any other.</p>

<p>Here is my code:</p>

<p><strong>HTML</strong></p>

<pre><code>&lt;body&gt;

&lt;h1 id="OTM_Test"&gt;Javascript Probability&lt;/h1&gt;

&lt;div id="stackoverflow"&gt;

&lt;a href="nextpage.html" id="button1" class="button"&gt;Next Page 1&lt;/a&gt;
&lt;a href="nextpage.html" id="button2" class="button"&gt;Next Page 2&lt;/a&gt;
&lt;a href="nextpage.html" id="button3" class="button"&gt;Next Page 3&lt;/a&gt;
&lt;a href="nextpage.html" id="button4" class="button"&gt;Next Page 4&lt;/a&gt;
&lt;a href="nextpage.html" id="button5" class="button"&gt;Next Page 5&lt;/a&gt;
&lt;a href="nextpage.html" id="button6" class="button"&gt;Next Page 6&lt;/a&gt;

&lt;/div&gt;

&lt;/body&gt;
</code></pre>

<p><strong>CSS</strong>
    <code>.button{
    background:blue;
    color:white;
    display:none;
    margin:200px;
    padding:10px;
    display:none;
    border:2px solid red;
    }</code></p>

<p><strong>Javascript/jQuery</strong></p>

<pre><code>$(document).ready(function(){

var button1 = $("#button1");
var button2 = $("#button2");
var button3 = $("#button3");
var button4 = $("#button4");
var button5 = $("#button5");
var button6 = $("#button6");

var totalArray = [button1,button2,button3,button4,button5,button6];



function randomChoice(){
    var randomNumber=Math.floor(Math.random()*6);
    return randomNumber;
    };



var selectedArray = [(totalArray[(randomChoice())]), (totalArray[(randomChoice())])];

function reduceArray(){
    for(i=0;i&lt;selectedArray.length;i++){
        (selectedArray[i]).show();
        }
};

reduceArray();

});
</code></pre>

<p>Any ideas/thoughts would be gratefully received.</p>

<p>It is my first post on here...please be gentle!</p>
