title: How to make own wait function using async
body: <p>I am trying to make a <code>wait</code> function that takes a time and waits for that time, but it is not working as I expect it to.</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>var wait = async (t)=&gt;{
      var c = new Promise((resolve,reject)=&gt;{setTimeout(()=&gt;{resolve()},t)})
      await c
      console.log(2)
  }
  console.log(1)
  wait(100)
  console.log(3)</code></pre>
  </div>
  </div>
  </p>
  
  <p>I know I can wait with plain <code>setTimeout()</code>, but I do not want to use that.</p>