title: Can not reference a variable in enclosing loop statement
body: <p>Ok so here is the new code that appends a table however it is running ALL of the final for in loop on the final td2 rather than running it on each td2 each instance of the loop.</p>
  
  <p>This is the full function updated:</p>
  
  <pre><code>function createRooms() {
      i = 0;
      var tbl = document.createElement("table");
  
      for (room in rooms) {
          i++;
  
          var rowid = "row" + i;
          var mytable = document.getElementById("lado");
  
          var tr = mytable.insertRow();
          tr.id = rowid; tr.className = 'row-cont';   
  
          var leftid = "title-cell-" + i;
          var rightid = "beds-cell-" + i;
  
          var td1 = tr.insertCell();
          var td2 = tr.insertCell();
          td1.id = leftid; td1.className = 'room-title-cell';
          td2.id = rightid; td2.className = 'room-beds-cell';
  
  
          for (var j = 0; j &lt; rooms[j].beds; j++ ) {
  
              var bedtable = td2.appendChild(tbl);
              var bedid = (rowid +  "-" + j);
  
              var bedrow = bedtable.insertRow();
              bedrow.id = bedid; bedrow.className = 'bed-cont';
  
              for (var b = 1; b &lt; daysThisMonth; b++) {
                  var bedcellid = bedid + "-" + b;
  
                  var bedcell = bedrow.insertCell();
                  bedcell.id = bedcellid; bedcell.className = 'bed-cell ' + "c" + b ;
              };
  
          };
  
      };
  
  };
  </code></pre>