title: Perform .join on value in array of objects
body: <p>If I have an array of strings, I can use the <code>.join()</code> method to get a single string, with each element separated by commas, like so:</p>
  
  <pre><code>["Joe", "Kevin", "Peter"].join(", ") // =&gt; "Joe, Kevin, Peter"
  </code></pre>
  
  <p>I have an array of objects, and I’d like to perform a similar operation on a value held within it; so from</p>
  
  <pre><code>[
    {name: "Joe", age: 22},
    {name: "Kevin", age: 24},
    {name: "Peter", age: 21}
  ]
  </code></pre>
  
  <p>perform the <code>join</code> method only on the <code>name</code> attribute, to achieve the same output as before.</p>
  
  <p>Currently I have the following function:</p>
  
  <pre><code>function joinObj(a, attr){
    var out = [];
  
    for (var i = 0; i &lt; a.length; i++){
      out.push(a[i][attr]);
    }
  
    return out.join(", ");
  }
  </code></pre>
  
  <p>There’s nothing wrong with that code, it works, but all of a sudden I’ve gone from a simple, succinct line of code to a very imperative function. Is there a more succinct, ideally more functional way of writing this?</p>