​Hi guys , wrking on a code in node js , i have a for loop and need to trigger the function once the for loop finish the excution

​Hi guys , wrking on a code in node js , i have a for loop and need to trigger the function once the for loop finish the excution ,
let data=[];
for(let i=0;i<someArray.length;i++){

data.push(someArr[i].name)

}

console(data)

but i always end up getting data as empty array ...
You already invited:

Amos

Upvotes from:

@James Since Js is not synchronous you are print before your array is done, you create a function for add the data inside your array and print the return of this function.

If you wanna answer this question please Login or Register