I have to iterate over an array inside an async funtion. The function does not seem to terminate at the resturn statement but continues further.
I am using:
async function f(args){
...
...
...
arr.forEach((z) => {
if (condition)
{
console.log("Should be true");
return true;
}
});
console.log("Should not reach here");
return false;
}
When I call the function with, the console has both the statements logged while the value returned is false when it must be true.
const res = await f(args);
console.log("RES: ", res);
Should be true
Should not reach here
RES: false;
The same thing happens if I use map.