title: How can I get a specific object from an array in javascript?
body: <p>I am trying to find an object in an array that meets specific conditions. I have an array created from a CSV file that gives the following result:</p>
  <pre><code>0: {production_company: &quot;Columbia Pictures&quot;, Pass: 50, Fail: 65, total: 115}
  1: {production_company: &quot;Universal Pictures&quot;, Pass: 47, Fail: 65, total: 112}
  2: {production_company: &quot;Warner Bros.&quot;, Pass: 38, Fail: 74, total: 112}
  
  </code></pre>
  <p>Then I have a dropdown menu with checkboxes where I check which one was &quot;checked&quot; using jQuery selector and on Change handler. I can get the attribute id so far. In the following code I am using the find method:</p>
  <pre><code>        var rowConverter_P = function(d) {
                  return {
                          production_company: d.production_company,
                          Pass: parseInt(d.Pass),
                          Fail: parseInt(d.Fail)
                 
                  };
                }
  
  d3.csv(production_dataset_url, rowConverter_P).then(function(data){
  
  d3.selectAll(&quot;input&quot;).on(&quot;change&quot;, function(){
  
                 
                          var paragraphID = d3.select(this).attr(&quot;id&quot;);
                          console.log(&quot;paragraph id&quot;, paragraphID); //this works
            
                          if($(this).is(&quot;:checked&quot;)) {
                                 
  
                         var new_data= data.find(d =&gt; d.production_company == paragraphID);
                                  console.log(&quot;new data: &quot;, new_data);}
  }});
  </code></pre>
  <p>my Html code:</p>
  <pre><code>&lt;div class=&quot;dropdown-menu&quot;&gt;
              &lt;button class=&quot;dropdown-item&quot; type=&quot;button&quot;&gt;
               &lt;input type=&quot;checkbox&quot; id=&quot;Columbia Pictures&quot; checked&gt; Columbia Pictures
               &lt;/button&gt;
              &lt;button class=&quot;dropdown-item&quot; type=&quot;button&quot;&gt;
                  &lt;input type=&quot;checkbox&quot; id=&quot;Universal Pictures&quot; checked&gt; Universal Pictures
              &lt;/button&gt;
              &lt;button class=&quot;dropdown-item&quot; type=&quot;button&quot;&gt;
                  &lt;input type=&quot;checkbox&quot; id=&quot;Warner Bros.&quot; checked&gt; Warner Bros.
              &lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  <p>The issue here is that I get the variable new_data = Undefined. I thought that maybe because I am comparing two values with different data types, I converted the variable paragraphID to a string as I parse production_company as a string earlier, but still, it is undefined. what am I missing here?</p>