title: return and scope for jquery each() function within an each() function
body: <p>I'm have markup like this:</p>
  
  <pre><code>&lt;div class="imagegroup"&gt;
      &lt;img&gt;
      &lt;img&gt;
      &lt;img&gt;
  &lt;/div&gt;
  &lt;div class="imagegroup"&gt;
      &lt;img&gt;
      &lt;img&gt;
      &lt;img&gt;
  &lt;/div&gt;
  &lt;div class="imagegroup"&gt;
      &lt;img&gt;
      &lt;img&gt;
      &lt;img&gt;
  &lt;/div&gt;​
  </code></pre>
  
  <p>And I want to separately get the height of the tallest image in each group. I've got a jquery <code>each</code> function within an <code>each</code> function:</p>
  
  <pre><code>$('.imagegroup').each(function(index) {
      var tallestHeight = 0;
      var slideshowNumber = index; 
      var slides = $(this).children();
  
      $(slides).each(function(index) {
          thisSlideHeight = $(this).height();
          console.log("In slideshow #" + slideshowNumber + ", slide #" + index + " has height " + thisSlideHeight);
          if (thisSlideHeight &gt; tallestHeight) {
              var tallestHeight = thisSlideHeight;
          }
          return tallestHeight;
      });
  
      console.log("For slideshow " + slideshowNumber + " the tallest slide is " + tallestHeight);
  
  });
  </code></pre>
  
  <p>But I'm puzzled as to how to pass the result of the inner each function "one level" up into the "outer" each function without just setting a global variable. <code>tallestHeight</code> stays at zero as I've written this.  I realize this is <em>super</em> beginner :) All help very appreciated.</p>
  
  <p><a href="http://jsfiddle.net/m2aJu/" rel="nofollow">http://jsfiddle.net/m2aJu/</a></p>