Here's the code in question:
let newArr = []
const items = [
{
name: 'JTB 0110-01',
offers: ['one', 'two']
},
{
name: 'LOBA CHEMIE',
offers: ['three', 'four', 'five']
},
//more
]
items.forEach(item => {
item.offers.forEach(i => newArr.push(i));
})
//more code
My goal is to iterate over the items array and push each offers property to a new array.
While the code works, I want the iteration to be completed before moving on to the next section of code. How can I achieve this?
Update
Apologies for the confusion. I am looking for a way to make the iteration synchronous, so that the loop finishes before proceeding to the next part of the code.