How to randomly choose one div out of a group and assign an event to it
<p>I'm trying to randomly choose one div out of a group and assign a click event to just the selected one. Below is the code I wrote thus far.</p>

<pre><code>&lt;div id="div1"&gt; &lt;/div&gt;
&lt;div id="div2"&gt; &lt;/div&gt;
&lt;div id="div3"&gt; &lt;/div&gt;
&lt;div id="div4"&gt; &lt;/div&gt;

&lt;script&gt;

var div1 = document.getElementById("div1");
var div2 = document.getElementById("div2");
var div3 = document.getElementById("div3");
var div4 = document.getElementById("div4");



var randomnumber = Math.floor(Math.random() * (4 - 1 + 1)) + 1;

var bomb = "div" + randomnumber;


alert(bomb);

bomb.onclick = function() { alert("You clicked me...BOOM!")}; // does not work


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