title: How to assign object values using asynchronous functions in javascript
body: <p>I am building a javascript object where some of the values are defined by asynchronous functions. My problem is the object gets defined faster than the asynchronous functions can return values:</p>
  
  <pre><code>    const array = ['a', 'b', 'c', 'd']
      const myArrayObj = [];
  
      function returnKey1 () {
          // make async call then store it in the return key1val:
          return key1val
      }
  
      function returnKey2 () {
          // make async call then store it in the return key2val:
          return key2val
      }
  
      function returnKey3 () {
          // make async call then store it in the return key3val:
          return key3val
      }
  
      _.forEach( array, function ( arr ) {
          myArrayObj.push({
              key1: returnKey1(), // returns undefined
              key2: returnKey2(), // returns undefined
              key3: returnKey3(), // returns undefined
        });
  
      });
  </code></pre>
  
  <p>Does anyone know the correct way I should be doing this? Thanks in advance! </p>