title: Can a loading sweet alert wait for a loop to finish before closing?
body: <p>I want to display a loading sweet alert while a loop is running. How can I make that possible. What currently happens is the sweet alert only opens for a split second after the loop has finished. I have tried making testFunc async and awaiting the wait function, but that didn't help. Not sure what to do at this point. I appreciate any help. Thank you so much</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function wait(ms) {
    var start = new Date().getTime();
    var end = start;
    while (end &lt; start + ms) {
      end = new Date().getTime();
    }
  }
  function testFunc() {
    sweetAlert({
      title: "Please wait",
      showCancelButton: false,
      showConfirmButton: false,
    });
  
    wait(3000);
    console.log("done");
    sweetAlert.close();
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.0/sweetalert.min.css" rel="stylesheet"/&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.0/sweetalert.min.js"&gt;&lt;/script&gt;
  &lt;button id="testBtn" onclick="testFunc()"&gt;TEST&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>Link to fiddle:
  <a href="https://jsfiddle.net/n4w8pf7L/22/" rel="nofollow noreferrer">https://jsfiddle.net/n4w8pf7L/22/</a></p>