title: How to filter object array based on attributes?
body: <p>I have the following JavaScript array of real estate home objects:</p>
  
  <pre><code>var json = {
      'homes': [{
              "home_id": "1",
              "price": "925",
              "sqft": "1100",
              "num_of_beds": "2",
              "num_of_baths": "2.0",
          }, {
              "home_id": "2",
              "price": "1425",
              "sqft": "1900",
              "num_of_beds": "4",
              "num_of_baths": "2.5",
          },
          // ... (more homes) ...     
      ]
  }
  
  var xmlhttp = eval('(' + json + ')');
  homes = xmlhttp.homes;
  </code></pre>
  
  <p>What I would like to do is be able to perform a filter on the object to return a subset of "home" objects.</p>
  
  <p>For example, I want to be able to filter based on: <code>price</code>, <code>sqft</code>, <code>num_of_beds</code>, and <code>num_of_baths</code>.</p>
  
  <p>How can I perform something in JavaScript like the pseudo-code below:</p>
  
  <pre><code>var newArray = homes.filter(
      price &lt;= 1000 &amp; 
      sqft &gt;= 500 &amp; 
      num_of_beds &gt;=2 &amp; 
      num_of_baths &gt;= 2.5 );
  </code></pre>
  
  <p>Note, the syntax does not have to be exactly like above. This is just an example.</p>