After undergoing a time-consuming process, the sample below shows that the array values are returned 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;
}
The following code is meant to print the output of the function. Assistance is required:
console.log(myFunction())