Here is the sample after pass to some process which consume time , the values of array return empty
function myFunction() {
let myArray = [];
let pastArray = [1, 2, 6, 7, 8, 1, 9, 6, 0]
pastArray.forEach(item =>{
setTimeout(function(){ myArray.push(item) }, 10000);
})
return myArray;
}
here is the code for print the output of the function...help needed
console.log(myFunction())