Currently, I am leveraging vue.js
and lodash
to iterate through a list of events in order to extract the promoted events. My goal is to then store each event in a new object or array that holds a refined list of promoted events. However, instead of consolidating all objects into a single array, I am ending up with separate arrays for each object.
getPromotedEvents() {
// Retrieve a list of promoted events
_.forEach(this.events, (eventList) => {
if(eventList.promote_event){
let arr = [];
arr.push(eventList)
console.log(arr);
}
});
},
This results in [{}], [{}], [{}] being returned, as opposed to [{},{},{}].