title: JavaScript - Loop between two dates. Start and end date
body: <p>I'm trying to <code>console.log</code> all the dates between two dates.</p>
  
  <p>Here is the code i have so far:</p>
  
  <pre><code>    var dString = "18.04.2018";
      var dParts = dString.split('.');
      var in30Days = new Date(dParts[2] + '/' +
                              dParts[1] + '/' +
                              (+dParts[0] + 10)
                     );
      var endDate =  in30Days.getDate() + "." + (in30Days.getMonth()+1) + "." +in30Days.getFullYear();     
      console.log("Now:" + dString + " EndDate: " + endDate);
  
      for (var d = dString; d &lt;= endDate; d.setDate(d.getDate() + 1)) {
          var loopDay = new Date(d);
          console.log("Day:" + loopDay);
      }
  </code></pre>
  
  <p>The end date is the start date plus 10 days.</p>
  
  <p>Here is the console log output i receive:</p>
  
  <pre><code>Now:18.04.2018 EndDate: 28.4.2018
  Day:Invalid Date
  </code></pre>
  
  <p>Why the date is invalid. Where is my mistake ?</p>