title: JS nested array.map
body: <p>Hi I have the following data:</p>
  
  <pre><code>data = [{due_at: '2019-09-10', yards:[{name: 'test'},{name: 'test2'}]}...]
  </code></pre>
  
  <p>I am wanting to iterate over this date to result in:</p>
  
  <pre><code>events = [{start: '2019-09-10', end: '2019-09-10, title: 'test'},{start: '2019-09-10', end: '2019-09-10, title: 'test2'}...]
  </code></pre>
  
  <p>I have tried using the following nested map:</p>
  
  <pre><code>events = data.map(d =&gt; {
      return d.yards.map(y =&gt; {
        return {
          start: d.due_at,
          end: d.due_at,
          title: y.name
        };
      });
    });
  </code></pre>
  
  <p>Which works to a point but I keep getting back a nested array like so:</p>
  
  <pre><code>[[{start: '2019-09-10', end: '2019-09-10, title: 'test'},{start: '2019-09-10', end: '2019-09-10, title: 'test2'}...]]
  </code></pre>
  
  <p>How can I adjust my map code to output a single array of objects?</p>