title: How to use a variable for a property name when using underscore.js findWhere function?
body: <p>I'm having trouble figuring out how to set a property dynamically in underscore.js while using the _.findWhere function.</p>
  
  <p>Here's the documentation for the function:</p>
  
  <blockquote>
  <pre><code>findWhere_.findWhere(list, properties) 
  </code></pre>
    
    <p>Looks through the list and returns the first value that matches all of
    the key-value      pairs listed in properties.</p>
    
    <p>If no match is found, or if list is empty, undefined will be returned.</p>
  
  <pre><code>_.findWhere(publicServicePulitzers, {newsroom: "The New York Times"});
  =&gt; {year: 1918, newsroom: "The New York Times",
  reason: "For its public service in publishing in full so many official reports,
  documents and speeches by European statesmen relating to the progress and
  conduct of the war."}
  </code></pre>
  </blockquote>
  
  <p>Modeling the example in the docs, I want to set the property to search for dynamically:</p>
  
  <pre><code> var publicServicePulitzers = [
      {"newsroom":"The New York Times", "year":2013 },
      {"newsroom":"The Los Angeles Times", "year":2012 }
   ];
  
  var myprop = 'newsroom';
  _.findWhere(publicServicePulitzers, { myprop : "The New York Times"});
  </code></pre>
  
  <p>The result is undefined.</p>
  
  <p>I also tried:</p>
  
  <pre><code>_.findWhere(publicServicePulitzers, {eval(myprop): "The New York Times"});
  </code></pre>
  
  <p>The error message is SyntaxError: missing : after property id</p>
  
  <p>How can I accomplish this?</p>
  
  <p>Thanks for any help.</p>