title: Javascript: Finding index of an object in an array, based on a value within a nested array on the objects
body: <p>I have an array that looks like this:</p>
  
  <pre><code>[{
      name: 'foobar',
      fields: [{
          label: 'argle'
      },{
          label: 'bargle'
      }]
  },{
      name: 'baz',
      fields: [{
          label: 'rar'
      },{
          label: 'hoogah'
      }]
  }]
  </code></pre>
  
  <p>I'm looking for the <em>index</em> of the object which has a <code>field</code> matching <code>label === 'rar'</code>, so I can update that particular field.  Is there an optimum way to accomplish this? I know <code>indexOf</code> won't get me there by itself, but I'm struggling with the logic.</p>