title: Increment variable every 5 iteration of for loop?
body: <p>I'm not 100% sure how to phrase this question, so feel free to change the Question title to something that makes sense.</p>
  
  <p>I have an object <code>solution</code> which contains a property name <code>days</code> which holds 10 arrays, see an example below</p>
  
  <pre><code>{
      "sameShiftHolds": true,
      "sameStaffHolds": true,
      "sameRoomHolds": true,
      "days": [{
          "availableStaff": [
              [0, 1, 4, 3, 5, 9, 22, 44],
              [0, 1, 4, 3, 5, 9, 22, 44],
              [4, 8, 7]
          ],
          "availableRooms": [
              [3, 6, 77, 89, 23],
              [3, 6, 77, 89, 23],
              [2, 7, 9]
          ],
          "suitableStaff": [
              [22, 44],
              [22, 44],
              [4]
          ],
          "suitableRooms": [
              [89, 23],
              [22, 44],
              [2]
          ],
          "ValidStartDate": true
      }, {
          "availableStaff": [
              [0, 1, 4, 3, 5, 9, 22, 44],
              [0, 1, 4, 3, 5, 9, 22, 44],
              [4, 8, 7]
          ],
          "availableRooms": [
              [3, 6, 77, 89, 23],
              [3, 6, 77, 89, 23],
              [2, 7, 9]
          ],
          "suitableStaff": [
              [22, 44],
              [22, 44],
              [4]
          ],
          "suitableRooms": [
              [89, 23],
              [22, 44],
              [2]
          ],
          "ValidStartDate": false
      }, {
          "availableStaff": [
              [0, 1, 4, 3, 5, 9, 22, 44],
              [0, 1, 4, 3, 5, 9, 22, 44],
              [4, 8, 7]
          ],
          "availableRooms": [
              [3, 6, 77, 89, 23],
              [3, 6, 77, 89, 23],
              [2, 7, 9]
          ],
          "suitableStaff": [
              [22, 44],
              [22, 44],
              [4]
          ],
          "suitableRooms": [
              [89, 23],
              [22, 44],
              [2]
          ],
          "ValidStartDate": true
      }, {
          "availableStaff": [
              [0, 1, 4, 3, 5, 9, 22, 44],
              [0, 1, 4, 3, 5, 9, 22, 44],
              [4, 8, 7]
          ],
          "availableRooms": [
              [3, 6, 77, 89, 23],
              [3, 6, 77, 89, 23],
              [2, 7, 9]
          ],
          "suitableStaff": [
              [22, 44],
              [22, 44],
              [4]
          ],
          "suitableRooms": [
              [89, 23],
              [22, 44],
              [2]
          ],
          "ValidStartDate": true
      }, {
          "availableStaff": [
              [0, 1, 4, 3, 5, 9, 22, 44],
              [0, 1, 4, 3, 5, 9, 22, 44],
              [4, 8, 7]
          ],
          "availableRooms": [
              [3, 6, 77, 89, 23],
              [3, 6, 77, 89, 23],
              [2, 7, 9]
          ],
          "suitableStaff": [
              [22, 44],
              [22, 44],
              [4]
          ],
          "suitableRooms": [
              [89, 23],
              [22, 44],
              [2]
          ],
          "ValidStartDate": true
      }, {
          "availableStaff": [
              [0, 1, 4, 3, 5, 9, 22, 44],
              [0, 1, 4, 3, 5, 9, 22, 44],
              [4, 8, 7]
          ],
          "availableRooms": [
              [3, 6, 77, 89, 23],
              [3, 6, 77, 89, 23],
              [2, 7, 9]
          ],
          "suitableStaff": [
              [22, 44],
              [22, 44],
              [4]
          ],
          "suitableRooms": [
              [89, 23],
              [22, 44],
              [2]
          ],
          "ValidStartDate": true
      }, {
          "availableStaff": [
              [0, 1, 4, 3, 5, 9, 22, 44],
              [0, 1, 4, 3, 5, 9, 22, 44],
              [4, 8, 7]
          ],
          "availableRooms": [
              [3, 6, 77, 89, 23],
              [3, 6, 77, 89, 23],
              [2, 7, 9]
          ],
          "suitableStaff": [
              [22, 44],
              [22, 44],
              [4]
          ],
          "suitableRooms": [
              [89, 23],
              [22, 44],
              [2]
          ],
          "ValidStartDate": true
      }, {
          "availableStaff": [
              [0, 1, 4, 3, 5, 9, 22, 44],
              [0, 1, 4, 3, 5, 9, 22, 44],
              [4, 8, 7]
          ],
          "availableRooms": [
              [3, 6, 77, 89, 23],
              [3, 6, 77, 89, 23],
              [2, 7, 9]
          ],
          "suitableStaff": [
              [22, 44],
              [22, 44],
              [4]
          ],
          "suitableRooms": [
              [89, 23],
              [22, 44],
              [2]
          ],
          "ValidStartDate": true
      }, {
          "availableStaff": [
              [0, 1, 4, 3, 5, 9, 22, 44],
              [0, 1, 4, 3, 5, 9, 22, 44],
              [4, 8, 7]
          ],
          "availableRooms": [
              [3, 6, 77, 89, 23],
              [3, 6, 77, 89, 23],
              [2, 7, 9]
          ],
          "suitableStaff": [
              [22, 44],
              [22, 44],
              [4]
          ],
          "suitableRooms": [
              [89, 23],
              [22, 44],
              [2]
          ],
          "ValidStartDate": false
      }, {
          "availableStaff": [
              [0, 1, 4, 3, 5, 9, 22, 44],
              [0, 1, 4, 3, 5, 9, 22, 44],
              [4, 8, 7]
          ],
          "availableRooms": [
              [3, 6, 77, 89, 23],
              [3, 6, 77, 89, 23],
              [2, 7, 9]
          ],
          "suitableStaff": [
              [22, 44],
              [22, 44],
              [4]
          ],
          "suitableRooms": [
              [89, 23],
              [22, 44],
              [2]
          ],
          "ValidStartDate": true
      }]
  }
  </code></pre>
  
  <p>On my site I have a custom made calendar view of a week, which is created from a template, starting from Monday to Friday. By default, there are 2 weeks but a user can change how many weeks they want to see. Each week is split up by a div with a unique id <code>"solCol0"</code>, <code>"solCol1"</code> etc....</p>
  
  <p><a href="https://i.stack.imgur.com/t9EFn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t9EFn.png" alt="enter image description here"></a></p>
  
  <p>I then loop through the number of weeks selected, in this case we have <code>2</code>.
  And then loop through the length of <code>solution</code> which is <code>10</code> in this case.
  I only want to loop 5 times (for each day of week) and then after 5 loops, increment the columdId by 1 to append the details onto the next week, for example the first 5 loops are appended to <code>"solCol0"</code> and then the next 5 are appended to "<code>solCol1</code>" and if the user has selected more than 2 weeks, to 3, <code>solution</code> length would increase to 15 so the next 5 loops would append to "'solCol2"` etc...</p>
  
  <p>Sorry if this isn't very clear, in general I just have to increment a value after every 5 loops. Any help would be greatly appreciated.</p>
  
  <pre><code>loadSolutionStartRows: function(dates, solution) {
      var self = this;
      for (var i = 0; i &lt; dates.length; i++) {
          var columnId = "#solCol" + i;
          var startDate = moment(dates[i], 'Do MMM');
          var rowDates = [];
          var iterate = 5;
          for (var d = 0; d &lt; solution.days.length; d++) {
              //Every 5 loops - columnId = "#solCol" + i + 1;
              rowDates.push(moment(startDate).format('ddd (Do MMM)'));
              startDate.add(1, 'days');
              var selectedDate = rowDates[d];
  
              var statusClass;
              var statusIconClass;
              if (solution.days[d].ValidStartDate === true) {
                  statusClass = "sxpTableHeaderIconGreenStatus";
                  statusIconClass = "octicon " + "octicon-check";
              }
              if (solution.days[d].ValidStartDate === false) {
                  statusClass = "sxpTableHeaderIconRedStatus";
                  statusIconClass = "octicon " + "octicon-x";
              }
  
  
              $(columnId).append(self.solutionTableRow({
                  rowId: i + 1,
                  date: selectedDate,
                  statusClass: statusClass,
                  statusIconClass: statusIconClass,
                  trainerCountEarly: 1,
                  trainerListEarly: 1,
                  roomCountEarly: 1,
                  roomListEarly: 1,
                  trainerCountLate: 1,
                  trainerListLate: 1,
                  roomCountLate: 1,
                  roomListLate: 1
              }));
          }
      }
  }
  
  },
  </code></pre>
  
  <p>With the code above I achieve the image below, it adds 10 days instead of the 5 as I want.</p>
  
  <p><a href="https://i.stack.imgur.com/xy6Kx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xy6Kx.png" alt="enter image description here"></a></p>