title: How to access the results of two nested .forEach in the larger function
body: <p>The pen is here: <a href="https://codepen.io/BradCoffield/pen/WEWXqO" rel="nofollow noreferrer">https://codepen.io/BradCoffield/pen/WEWXqO</a></p>
  
  <p>I have a getJSON and inside of it I'm processing returned data and building what should get sent to the HTML using 2 <code>.forEach</code></p>
  
  <p>I want to pull the results of each <code>.forEach</code>, concatenate them and append them to an ID. But the variables aren't accessible to the outer area of the function and I don't know what to do.</p>
  
  <pre><code>$(document).ready(function () {
  
  $.getJSON("https://api3.libcal.com/api_hours_grid.php?iid=000&amp;format=json&amp;weeks=1&amp;systemTime=0&amp;callback=?", function (json) {
  
      var day0 = (json.locations[0].weeks[0].Sunday);
      var day1 = (json.locations[0].weeks[0].Monday);
      var day2 = (json.locations[0].weeks[0].Tuesday);
      var day3 = (json.locations[0].weeks[0].Wednesday);
      var day4 = (json.locations[0].weeks[0].Thursday);
      var day5 = (json.locations[0].weeks[0].Friday);
      var day6 = (json.locations[0].weeks[0].Saturday);
  
      var days = [day0, day1, day2, day3, day4, day5];
      var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
  
  
      dayNames.forEach(function (foo) {
          var someContent = "&lt;li id='" + foo + '-hours'+"'&gt;&lt;span class='day-of-week'&gt;" + foo + ", "
  
  
      });
  
      days.forEach(function (element) {
  
          var dayDate = element.date
          var dayDay = element.rendered
  
          if (dayDate[5] === '0') {
              dayDate = dayDate.substr(6)
          } else {
              dayDate = dayDate.substr(5)
          }
  
          var moreContent = "" +  dayDate + ":&lt;/span&gt; " + "&lt;span class='dates'&gt;" + dayDay + "&lt;/li&gt;"
  
      });
  
  
      var forHTML = someContent + moreContent;
  
  
      $('#this-weeks-hours').append(forHTML);
  
  
  });});
  </code></pre>