Reputation: 376
let arrData = [];
arrGotData.forEach(function(objGotData) {
let arrDataLength = arrData.length;
//do something
arrData[arrDataLength] = objGotData;
}
return arrData;
How could I return my arrData AFTER the forEach got executed and not before?
Upvotes: 0
Views: 126
Reputation: 29715
You are missing the bracket )
after }
Check out the working code here
Adding the same code here for reference
fun() {
let arrData = [];
this.arrGotData.forEach((objGotData) => {
let arrDataLength = arrData.length;
//do something
arrData[arrDataLength] = objGotData;
});
return arrData;
}
Upvotes: 1