title: How to generate dynamic array of objects in typescript
body: <p>I want to pass the array of string <code>names</code> in to the function and be able to generate the array of objects based on that.</p>
  
  <p>Say I am passing <code>{ 'id', 'title' }</code> and as an output I am getting</p>
  
  <pre><code>[
      {
        id: '1',
        title: 'o1'
      },
      {
        id: '2',
        title: 'o2'
      },
  ]
  </code></pre>
  
  <p>I am kind of stucked as not sure how would you take the array of stirngs and convert its elements in to an object</p>
  
  <pre><code>export function getItems(names) {
  
    const a: any[] = [];
    for (let i = 0; i &lt; 5; i++) {
        // need to produce 5 objects here like:
        // {
        //  id: '1',
        //  title: 'o1'
        // }
        a.push(object);
    }
  
    return a;
  }
  </code></pre>
  
  <p>thoughts?</p>