'use strict';


var locationsInfo = [
['1st and Pike' , 23 , 65 ,6.3],
['SeaTac Airport', 3 ,24 , 1.2],
['Seattle Center', 11, 38 , 3.7],
['Capitol Hill', 20,38 , 2.3],
['Alki', 2 ,16 , 4.6],
];


function Store (name, minCustomer, maxCustomer, avgCookieSale) {
  this.name = name;
  this.minCustomer = minCustomer;
  this.maxCustomer = maxCustomer;
  this.avgCookieSale = avgCookieSale;
}

Store.prototype.customersPerHour = function() {
  return Math.random() * (this.maxCustomer - this.minCustomer) + this.minCustomer;
};

var stores = [];

for(each in locationsInfo){
  stores.push(
    new Store(
            locationsInfo[each][0],
            locationsInfo[each][1],
            locationsInfo[each][2],
            locationsInfo[each][3]
            )
  );
}

var hours = [ '6am', '7am', '8am', '9am', '10am', '11am', '12pm', '1pm', '2pm', '3pm', '4pm', '5pm', '6pm', '7pm', '8pm'];

for (var i = 0; i < stores.length; i += 1){
  var locationsStats = [];
  var store = stores[i];
  var totalCookiesSold = 0;
  for (var j = 0; j < hours.length; j += 1){
    var flooredNumber = Math.floor(store.avgCookieSale * store.customersPerHour());
    // | Int Value of average sold | String description
    locationsStats.push(flooredNumber);
    totalCookiesSold += flooredNumber;
  }
  console.log(locationsStats);
  store.locationsStats = locationsStats;
  store.totalCookiesSold = totalCookiesSold;
}

var parentMyElement = document.getElementById('mylistsOfStats');
console.log(document);
console.log(parentMyElement);

for (var each = 0; each < stores.length; each += 1){
  var eachStore = stores[each];
  var article = document.createElement('article');
  parentMyElement.appendChild(article);
  var title = document.createElement('h2');
  title.textContent = eachStore.name;
  article.appendChild(title);
  var ul = document.createElement('ul');
  article.appendChild(ul);

  for (var eachList = 0; eachList < eachStore.locationsStats.length; eachList += 1){
    var li = document.createElement('li');
    li.textContent = eachStore.locationsStats[eachList];
    ul.appendChild(li);
  }
  var liLast = document.createElement('li');
  liLast.textContent = 'Total: ' + eachStore.totalCookiesSold + ' cookies';
  ul.appendChild(liLast);

}

@@ -541,20 +541,22 @@
 %5D;%0A%0Afor(
+var 
 ea
-ch
  in loca
@@ -625,18 +625,16 @@
 sInfo%5Bea
-ch
 %5D%5B0%5D,%0A  
@@ -659,18 +659,16 @@
 sInfo%5Bea
-ch
 %5D%5B1%5D,%0A  
@@ -693,18 +693,16 @@
 sInfo%5Bea
-ch
 %5D%5B2%5D,%0A  
@@ -727,18 +727,16 @@
 sInfo%5Bea
-ch
 %5D%5B3%5D%0A   
@@ -1386,24 +1386,260 @@
 iesSold;%0A%7D%0A%0A
+Store.prototype.renderStats = function(parentElement)%7B%0A  for(var statKey in this.locationsStats)%7B%0A    var li = document.createElement('li');%0A    li.textContent = this.locationsStats%5BstatKey%5D;%0A    parentElement.appendChild(li);%0A  %7D%0A%7D;%0A%0A%0A
 var parentMy
@@ -2105,221 +2105,36 @@
 l);%0A
-%0A  for (var eachList = 0; eachList %3C eachStore.locationsStats.length; eachList += 1)%7B%0A    var li = document.createElement('li');%0A    li.textContent = eachStore.locationsStats%5BeachList%5D;%0A    ul.appendChild(li);%0A  %7D
+  eachStore.renderStats(ul);
 %0A  v

replace loop with method on prototype