title: Javascript function works but returns undefined
body: <p>I'm trying to build a function that looks for all elements with the 'filter' rel in my page, and then adds them to a js object.</p>
  
  <p>The function itself seems to work fine when I use console.log within the function, however, when I attempt to call the function anywhere it returns undefined.  I realize that this is a common issue with asynchronous calls, but I didn't think that was the case here:</p>
  
  <pre><code>function getFilters() {
  jQuery(document).ready(function($) {
      var filters = new Array();
      $("[rel=filter]").each(function(i,e){
          var type = $(e).attr('type');
          if(type == 'checkbox') { if($(e).is(':checked')) var val = $(e).prop('checked'); }
          else if(type == 'radio') { if($(e).is(':checked')) var val = $(e).val(); }
          else var val = $(e).val();
          if(val) filters.push({name : $(e).attr('name'), value : val});
      });
      return filters;
  });
  }
  </code></pre>
  
  <p>Again, when I run console.log(filters); in place of return filters; my data pulls up just fine.  When I attempt to return it though, it just results in undefined.  Any help is much appreciated.</p>