title: javascript promise in nested loop
body: <p>Im trying unsuccessfully to loop through an array that has an array as one of the params, I need to loop through that nested array in order to map it according to specs, then I need to run a function after the parent loop completes.  Can someone point out my mistake on getting this accomplished?   </p>
  
  <pre><code>const schedule = {}
  data.schedule.forEach(item =&gt; {
    let date = moment(item.date).format('YYYY-MM-DD')
    let eventList = []
    item.events.forEach(event =&gt; {
      let start = moment(event.start).format('h:mm A')
      let end = moment(event.end).format('h:mm A')
      let time = `${start} - ${end}`
      eventList.push({time: time, name: event.name})
    })
    return Promise.all(eventList).then(list =&gt; {
      console.log('list', list)
      schedule[`${date}`] = list
    })
  })
  
  // this is my issue:
  
  Promise.all(schedule).then(list =&gt; {
    console.log('schedule:', list)
  })
  
  // which bombs the method with:
  // TypeError: (var)[Symbol.iterator] is not a function
  // at Function.all (native)
  </code></pre>
  
  <p>I actually need to return an object that resembles this:</p>
  
  <pre><code>{'2017-12-06': [
    {time: '9am - 10am', name: 'Jackson Home'},
    {time: '11AM - 3PM', name: 'Jackson Home'},
    {time: '3PM - 8PM', name: 'Jackson Home'}
  ]}
  </code></pre>