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?
const schedule = {}
data.schedule.forEach(item => {
  let date = moment(item.date).format('YYYY-MM-DD')
  let eventList = []
  item.events.forEach(event => {
    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 => {
    console.log('list', list)
    schedule[`${date}`] = list
  })
})
// this is my issue:
Promise.all(schedule).then(list => {
  console.log('schedule:', list)
})
// which bombs the method with:
// TypeError: (var)[Symbol.iterator] is not a function
// at Function.all (native)
I actually need to return an object that resembles this:
{'2017-12-06': [
  {time: '9am - 10am', name: 'Jackson Home'},
  {time: '11AM - 3PM', name: 'Jackson Home'},
  {time: '3PM - 8PM', name: 'Jackson Home'}
]}
 
    