title: Javascript promise.all()
body: <p>I have this piece of code.</p>
  <pre><code>function a() {
    var promise1 = Promise.resolve(3);
    var promise2 = 42;
    var promise3 = new Promise(function(resolve, reject) {
      setTimeout(resolve, 2000, 'foo');
    });
  
    Promise.all([promise1, promise2, promise3]).then(function(values) {
      console.log(&quot;done&quot;, values);
    });
  }
  
  async function b() {
   await a(); 
  }
  
  b();
  console.log(&quot;here&quot;)
  </code></pre>
  <p>Here, we get the output</p>
  <blockquote>
  <p>&quot;here&quot;</p>
  </blockquote>
  <p>and then after two seconds, we get</p>
  <blockquote>
  <p>&quot;done&quot; Array [3, 42, &quot;foo&quot;]</p>
  </blockquote>
  <p>How do I change this code so that inside function b(), we are actually waiting for a() to complete and then continue the execution of the code?</p>
  <p>Hence, the output I want is</p>
  <p>Wait two seconds and see</p>
  <blockquote>
  <p>&quot;done&quot; Array [3, 42, &quot;foo&quot;]</p>
  <p>&quot;here&quot;</p>
  </blockquote>