title: Loop through array indexes that have the same key? (JavaScript/jQuery)
body: <p>I've been trying to run through the first index while checking <em>only</em> each index's <code>id</code>, not its name. I'm not trying to get every key->value within each element. Simply put, I only want to know each element's <code>id</code> value. If it matches the condition inside the loop, I want to display only its name.</p>
  
  <p>My problem is that it will grab the value of the index <code>i</code>, but not the value of <code>id</code>. </p>
  
  <pre><code>var offices = [
      {id: 1, name: "Miami"},
      {id: 2, name: "San Francisco"}
  ];
  
  
  for (i = 0; i &lt; offices.length; i++) {
  
      if (offices[i]['id'] === 1){
          $('#edit_office').val(offices[i]['name']);
          //#edit_office is an input[type="text"]
      }
  
  }
  </code></pre>
  
  <p>How would I do this?</p>
  
  <p>Your help is appreciated.</p>