title: How to reduce this code from two functions into one using for loop?
body: <p>Hi there can someone help me please I have this two functions:</p>
  
  <pre><code>$(document).ready(function(){ 
      sizeNestable(); 
  }); 
  
  $('#nestable1, #nestable2').change(function() {
      sizeNestable();
  });
  
  function sizeNestable() {
  
      var n3 = $('#nestable1').find('.dd3-handle').height('100%'); 
      var n4 = $('#nestable2').find('.dd3-handle').height('100%'); 
  
      var smallest; 
      var largest; 
  
      if(n3.size() &gt; n4.size()) { 
          largest = n3; 
          smallest = n4; 
      } else { 
          largest = n4; 
          smallest = n3; 
      } 
  
      for(var i = 0; i &lt; smallest.size(); i++) { 
          if(smallest.eq(i).height()  &gt; largest.eq(i).height()) { 
              largest.eq(i).height(smallest.eq(i).height()); 
          } else { 
              smallest.eq(i).height(largest.eq(i).height()); 
          }
      }
  }
  </code></pre>
  
  <p>That was the first one and the second function is this:</p>
  
  <pre><code>$(document).ready(function(){ 
     sizeNestable2(); 
  }); 
  
  $('#nestable3, #nestable4').change(function() {
     sizeNestable2();
  });
  
  function sizeNestable2() {
  
      var n3 = $('#nestable3').find('.dd3-handle').height('100%'); 
      var n4 = $('#nestable4').find('.dd3-handle').height('100%'); 
  
      var smallest; 
      var largest; 
  
      if(n3.size() &gt; n4.size()) { 
          largest = n3; 
          smallest = n4; 
      } else { 
          largest = n4; 
          smallest = n3; 
      } 
  
      for(var i = 0; i &lt; smallest.size(); i++) { 
          if(smallest.eq(i).height()  &gt; largest.eq(i).height()) { 
              largest.eq(i).height(smallest.eq(i).height()); 
          } else { 
              smallest.eq(i).height(largest.eq(i).height()); 
          }
      }
  }
  </code></pre>
  
  <p>Can someone please help me how can I make one function from this two is there a way to reduce this code because it will not look good every time   I need the nestable to add another function..?</p>