I am new to the world of node.js and Javascript and I have a loop that goes over an array of objects at a certain condition I need to call a function that does asnyc work and the loop to stop while the function isn't done
fucntion foo1(arr){
for(var i=0 ; arr.length>i ; i++){
if(i==8){//or any other condition
doAsyncStuff(hits[i])
}
}
}
function doAsyncStuff(item){
parser.parseURL(someurl,function(error,result){
item.someprop=result.someprop;
})
}
the problem is no matter what I do, I can't seem to make the function wait it end's before I have the result and doesn't update the item I need it to update. I understand it's a common issue but none of the solution I found worked. any help would be welcome. Thanks!
asynclibrary....forloop