title: Javascript Moment.js add to date (twice a month)
body: <p>I am using Moment.js and I need to create a for loop that adds a specific number of days to a date variable called <code>theDate</code>, so the <code>'theDate'</code> keeps advancing in a semi-monthly order (twice a month).</p>
  
  <p>This example works for adding a single day (one by one) to dueDate</p>
  
  <pre><code>for (var i = 1; i &lt;= 10; i++) {
      moment(theDate).add(i, 'day').add(1,'day');
      console.log(dueDate);
  }
  </code></pre>
  
  <p>And if the <code>'theDate'</code> is set to <code>18.Jan.2017</code>, then above will print the following:</p>
  
  <pre><code>1/18/17
  1/19/17
  1/20/17
  1/21/17
  1/22/17
  </code></pre>
  
  <p>...</p>
  
  <p>I need to figure out how to add the number of days (or weeks, etc.) so the result is adding days in a semi-monthly (twice a month) order. Meaning, if my starting date is set <code>18.Jan.2017</code>, the result should look like this for the entire year <code>2017</code>:</p>
  
  <pre><code>1/18/17
  2/01/17
  2/18/17
  3/04/17
  3/18/17
  4/01/17
  4/18/17
  5/02/17
  5/18/17
  6/01/17
  6/18/17
  7/02/17
  7/18/17
  8/01/17
  8/18/17
  9/01/17
  9/18/17
  10/02/17
  10/18/17
  11/01/17
  11/18/17
  12/02/17
  12/18/17
  </code></pre>
  
  <p>Please note that I am not looking for a 1 and 15th type of solution as we usually see with paycheques. I need twice a month payments based on a starting date, which can be anything user decides to set it to.</p>