How to wait for code within a function to finish before continuing

hello there, my first day here, I have a function that contains a loop that calls another function but each iteration completes without waiting for the inner function to complete.

function run()
    for(var x = 0; x < 10; x++)
          update_some_stuff(); ///the iteration aren't waiting for this to complete

I have tried using setTimeOut but it’s workings I don’t understand, how can I force the iteration to wait for the function update_some_stuff() to complete,


This sounds like a case where you would want to use a recursive function. The concept is a little advanced for day one.

If you could tell us more about what you’re attempting to solve and what you update_some_stuff function does, I can try to help you further.

```update_some_stuff()`` : open a link[the contents of this link changes alot] get an inventory,
got back to the previous url use the inventory, save the details of the inventory.

the loop iterations aren’t waiting for the function to complete a single call, the function update_some_stuff seems not to block the loop am not sure why.

please help me anyone.