Here is the loop I am currently using:
if (list.length) {
for (let i = 0; i < list.length; i++) {
let fruit = list[i].attributes;
if (fruit.color === 'red') {
id = fruit.id;
fruit.path = base.fruit_directory + "/" + id;
saveFruit(id);
}
}
}
I have noticed that even though a red fruit is encountered in the loop, the function to save the fruit is not executed immediately. Can anyone explain why this might be happening?
Is there any way to work around this issue?