title: How to make variable accessible within jQuery .each() function?
body: <p>This is and example of a frequent dilemma: how to make <code>markup</code> accessible inide this <code>.each()</code>?  </p>
  
  <p>I'm more interested in learning how to access outer variables from within a closure than I am in this specific issue.  I could fix this problem by assigning <code>markup</code> from inside the each function, but I'd rather learn a more elegant way to handle this kind of problem.  </p>
  
  <pre><code>// hide form &amp; display markup
  function assessmentResults(){
  
    // get assessment responses
    var markup = parseForm();
  
    // show assessment results to user
    $('#cps-assess-form fieldset').each( function() {
      var q = $(this).find('.fieldset-wrapper');
      var i = 0;
  
      // hide form questions
      q.slideUp();
  
      // insert markup
      $('&lt;div&gt;'+markup[i]+'&lt;/div&gt;').insertAfter(q);
      i++;
    });
  
  }
  </code></pre>