title: JavaScript async/await not awaiting properly?
body: <p>I'm having an issue with JavaScript's async/await functions.  This is happening on an internal application that I can't share the source for, but I put together a quick generic reproduction of my issue:</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 sleep(ms) {
    return new Promise(resolve =&gt; setTimeout(resolve, ms));
  }
  
  async function baz(input) {
    console.log("4");
    await sleep(1000);
    console.log("5");
    return input;
  }
  
  async function bar(input) {
    console.log("3");
    return await baz(input);
  }
  
  async function foo() {
    console.log("2");
    const foo = await bar("foo");
    return foo;
  }
  
  console.log("1");
  foo();
  console.log("6");</code></pre>
  </div>
  </div>
  </p>
  
  <p>I would expect this to return the following with a one second wait between <code>4</code> and <code>5</code>:</p>
  
  <pre><code>1
  2
  3
  4
  5
  6
  "foo"
  </code></pre>
  
  <p>Instead, after trying this in the console in Chrome 64.0.3282.167 and Firefox 58.0.2 I receive this:</p>
  
  <pre><code>1
  2
  3
  4
  6
  undefined
  5
  </code></pre>
  
  <p>Please can someone point out where I'm going wrong in this?</p>