Jquery function calling sequence
<p>I'm newbie to Jquery and saw this piece of code in a book.
I'm trying to understand how hideCode() is being executed.</p>

<p>This is my understanding of the sequence of evets thats going to happen:</p>

<ol>
<li>Document gets loaded and its ready to perform the jquery function.</li>
<li>When the guess_box is clicked run checkForCode() function.</li>
<li>hideCode() function runs.</li>
</ol>

<p>Is this correct?</p>

<pre><code>$(document).ready(function() {
   $(".guess_box").click(checkForCode);
   function getRandom(num) {
       var my_num = Math.floor(Math.random() * num);
       return my_num;
   }
   var hideCode = function() {
       var numRand = getRandom(4);
       $(".guess_box").each(function(index, value) { 
           if(numRand == index){
               $(this).append("&lt;span id='has_discount'&gt;&lt;/span&gt;");
               return false;
           }
       });
   }
   hideCode();
   function checkForCode() {
       var discount;
       if($.contains(this, document.getElementById("has_discount"))) {
          var my_num = getRandom(5);
          discount = "&lt;p&gt;Your Discount is " + my_num + "%&lt;/p&gt;";
       } else {
           discount = "&lt;p&gt;Sorry, no discount this time!&lt;/p&gt;" ;
       }
       $(this).append(discount);
       $(".guess_box").each(function() {
           $(this).unbind('click');
       });
</code></pre>
