Jquery: How to make this ternary operator start on an event?
<p>in this fiddle,<a href="http://jsfiddle.net/urfXq/79/" rel="nofollow">http://jsfiddle.net/urfXq/79/</a>, if you click on the black "button", it randomly chooses an element (red, green or blue) from an array. The array is graphically represented by the colored boxes at the top. Obviously the colored boxes at the top don`t need to be there.  </p>

<p>That part seems to work fine. Indeed, here`s a fiddle that shows the first part works jsfiddle.net/urfXq/46 . Assming this is the correct way to assign the random result to a variable (after converting it to lower case)</p>

<pre><code>$("#button").click(function() {
var ran = getRandom(myArray, true).toLowerCase();
});
</code></pre>

<p>the problems seem to start in the second part.  The user is supposed to guess which color was chosen. The user guesses by clicking on one of the colored boxes at the bottom. The guess is assigned to the variable "guess"</p>

<p>It is at this point--after the user guesses--that I want the ternary operator to be triggered and to compare variable "ran" with "guess". If they are the same, then box pink fades out. If they are different, box lime-green fades out. </p>

<p>This whole last function seems to be full of problems that I can`t figure out. </p>

<pre><code>//user clicks button to guess
$("#red,#blue, #green").click(function() {
  //if click blue is blue being assigned to guess?
    var guess = $(this);
 //ternary to compare if guess and random are equal
   $("guess===ran") ? results.fadeOut(1000) : wrong.fadeOut(1000);
  });
</code></pre>
