title: Pass value from promise to variable
body: <p>I tried to return the value from a Promise and assign it to a local variable inside the function, but the Promise gets fired at last.</p>
  
  <p>The function (which will get fired in Vue.js <code>mounted()</code>):</p>
  
  <pre><code>getPriceForYesterday(){
      let yesterdayUSD = [];
      for (let i = 0; i &lt; this.cryptos.length; i++) {
          let cryptoName = this.cryptos[i].title;
          let timestamp = new Date(this.cryptos[i].purchaseDate);
          timestamp.setDate(timestamp.getDate() - 1);
          timestamp = timestamp.toISOString();
  
          let priceYesterday = getPriceForTimestamp(cryptoName, timestamp);
          Promise.all([priceYesterday]).then((values) =&gt; {
              console.log("values", values)
              yesterdayUSD.push(values[0]);
          }).catch(e =&gt; console.error(e));
  
      }
      console.log("yesterdayUSD", yesterdayUSD);
      console.log("yesterdayUSD[0]", yesterdayUSD[0]);
  }
  </code></pre>
  
  <p>Output: </p>
  
  <pre><code>yesterdayUSD []
  yesterdayUSD[0] undefined
  values [13308.06]
  values [1278.69]
  </code></pre>
  
  <p>I want to use <code>yesterdayUSD</code> to compare it with a local storage value and then return the "result" of the comparison to the vue data.</p>