title: Promise.prototype.then() behavior
body: <p>I have this promise:</p>
  
  <pre><code>var seasonalityArray;   
  
      ...
  
  aService.gettingAnalysis(site, cohortKey)
              .then(function (result) {
                  let date = moment();
                  seasonalityArray = result.cooling.getSeasonMonths(date);
              })
              , function (error) {
                  console.error('An error occurred', error);
              };
  
  
  const totalAccounts = _.size(report.asModel().accountNumbers);
  
  const warnings = _.compact(_.map(seasonalityArray, function (monthLabel) {
  
                 ...
  
  }));
  </code></pre>
  
  <p>...</p>
  
  <pre><code>   aService.gettingAnalysis = function (site, Key) {
          return Promise.all([
              aService.findingHeat(site, Key),
              aService.findingCool(site, Key)
          ]).spread(function (heating, cooling) {
              return { heating: heating, cooling: cooling };
          });
      };
  </code></pre>
  
  <p>Inside <code>seasonalityArray</code> variable, it must get an array of months (e.g. <code>['June','July','August']</code>)  which will be used afterwards.</p>
  
  <p>The problem that I found while debugging each step is that after it goes in the line with <code>aService.gettingAnalysis</code> it doesn't enter in .<code>then()</code> and all the code after but it jumps to setting <code>totalAccounts</code> and afterwards it enters in warnings with <code>seasonalityArray</code> being <code>undefined</code>.</p>
  
  <p>Is there a way to make it enter inside <code>then()</code> or at least to set that variable before it is using it as <code>undefined</code>?</p>