JavaScript Loop and wait for function
- by Fluidbyte
I have a simple single-dimension array, let's say:
fruits = ["apples","bananas","oranges","peaches","plums"];
I can loop thru with with $.each() function:
$.each(fruits, function(index, fruit) {  
   showFruit(fruit);
});
but I'm calling to another function which I need to finish before moving on to the next item.
So, if I have a function like this:
function showFruit(fruit){
    $.getScript('some/script.js',function(){
        // Do stuff
    })
}
What's the best way to make sure the previous fruit has been appended before moving on?