title: Map an object array with unknown length and unknown key names
body: <p>Here are some object arrays:</p>
  
  <pre><code>1. [{id:'1', code:'somecode', desc:'this is the description'}, {...}, {...}]
  
  2. [{fname:'name', lname:'last name', address:'my address', email:'my@email.com'}, {...}, {...}]
  
  </code></pre>
  
  <p>What I need to do is create a function where I pass an array and map their object keys to generic keys so they become like this:</p>
  
  <pre><code>1. [{key1:'1', key2:'somecode', key3:'this is the description'}, {...}, {...}]
  
  2. [{key1:'name', key2:'last name', key3:'my address', key4:'my@email.com'}, {...}, {...}]
  </code></pre>
  
  <p>When I do this</p>
  
  <pre><code>let keys: string[] = Object.keys(this.options[0])
  this.replacedItems = this.options.map(item =&gt; {
    return{
      key1: item[keys[0]],
      key2: item[keys[1]],
      key3: item[keys[2]],
    }
  });
  </code></pre>
  
  <p>it works fine, but since the object's properties number is not fixed, I tried this</p>
  
  <pre><code>let keys: string[] = Object.keys(this.options[0])
  this.replacedItems = this.options.map(item =&gt; {
    let i=0;
    keys.forEach(key=&gt;{
      let newKey = 'key'+i;
      i++
      return { newKey: item[key] }
    });
  }); 
  </code></pre>
  
  <p>which rerurns an array of undefined...
  What am I doing wrong?</p>