title: How can I get array of dates between 2 dates?
body: <p>My case like this :</p>
  
  <pre><code>let arr = [
    {id:1,fromDate:'2019-06-01',toDate:'2019-06-03'},
    {id:2,fromDate:'2019-10-15',toDate:'2019-10-15'},
    {id:3,fromDate:'2019-12-01',toDate:'2019-12-03'},
    {id:4,fromDate:'2019-12-25',toDate:'2019-12-26'},
    {id:5,fromDate:'2019-12-29',toDate:'2019-12-31'}
  ]
  
  let tempDates = []
  
  arr.forEach(element =&gt; {
  
    let now = moment()
  
    let fromDate = moment(element.fromDate)
    let toDate = moment(element.toDate)
  
    if (fromDate &gt; now &amp;&amp; toDate &gt; now) {
      while (fromDate &lt;= toDate) {
        let ld = fromDate.format('YYYY-MM-DD')
        tempDates.push(ld)
      }
    }
  })
  </code></pre>
  
  <p>Demo and full code : <a href="https://codepen.io/positivethinking639/pen/yLLvWGR?editors=1010" rel="nofollow noreferrer">https://codepen.io/positivethinking639/pen/yLLvWGR?editors=1010</a></p>
  
  <p>I try use while to get array of date. But seems it make loop is not stop</p>
  
  <p>How can I solve this problem?</p>
  
  <p>I want to store fromDate in array tempDates</p>