title: sleep inside a for loop and a finally block
body: <p>I currently have the following loop </p>
  
  <pre><code>for (const pk of likerpk)
  {
       await likeMediaId(ig, pk.trim());
  
  }
  </code></pre>
  
  <p>the issue is that i wanted to call likeMediaId every X seconds and after the whole likeMediaId is done I wanted to call the function called Y</p>
  
  <p>I have tried putting a sleep inside a for loop but that does not help, it seems that it is still executing likeMediaId in parallel, while i always want to execute 1 likeMediaId at a time</p>
  
  <p>basically the flow that i wanted is (assuming 3 items in the array) </p>
  
  <pre><code>likeMediaId()
  sleep 60 seconds
  likeMediaId()
  sleep 60 seconds
  likeMediaId()
  sleep 60 seconds
  
  call function Y
  </code></pre>
  
  <p>what is the most elegant way in doing this?</p>