title: How do I wait for a promise to finish inside a loop? (without using async-await)
body: <p>The below code waits only for the 1st iteration of the for loop.
  If I use async-await, it works fine.
  So where am I going wrong here?</p>
  <pre><code>function wait(milliseconds) {
    return new Promise(resolve =&gt; setTimeout(resolve, milliseconds))
  }
  
  function countDown(count) {
    for (let i = count; i &gt; 0; i--) {
      wait(1000)
        .then(() =&gt; console.log(i))
        .catch((error) =&gt; console.log(error));
    }
  }
  
  countDown(5);
  </code></pre>