title: Create an object inside foreach
body: <p>I have a requirement to create an object in following format inside foreach loop </p>
  
  <pre><code>var array = ['sent', 'flag']
  </code></pre>
  
  <p>need an output object like the following format </p>
  
  <pre><code>obj = {
  sent: true,
  flag: true
  }
  </code></pre>
  
  <p>Tried </p>
  
  <pre><code>array.forEach(function(data){
      console.log('data', data);
      var obj = {}
      obj.data = true;
  })
  </code></pre>
  
  <p>Your help is much appreciated. Thank you. </p>