title: How can I load unlimited previous week from moment.js in my calendar?
body: <p>I want to load previous week when i click on previous month button infinite. I'm using this code but It's giving previous month for one time only. After one click It does not work. I'm using this code </p>
  
  <pre><code>function myFunction(e) {
      if(e == 1) {
          currentWeek = currentWeek + 1;
      }else if (e == -1){
          currentWeek = currentWeek - 1;
      }else {
          currentWeek = 0
      }
  
      var startOfWeek, endOfWeek;
      if(currentWeek == 0){
       startOfWeek= moment().isoWeekday(1).startOf('week');
       endOfWeek = moment().isoWeekday(1).endOf('week');
      //  console.log(startOfWeek);
      }else if(currentWeek &gt; 0) {
  
          startOfWeek = moment().add(currentWeek, 'weeks').startOf('week')
          endOfWeek = moment().add(currentWeek, 'weeks').endOf('week')
      }else{
          startOfWeek = moment().subtract(1, 'weeks').startOf('week')
          endOfWeek = moment().subtract(1, 'weeks').endOf('week')
      }
      var days = [];
      var day = startOfWeek;
  
      while (day &lt;= endOfWeek) {
          days.push(day.toDate());
          day = day.clone().add(1, 'd');
      }
  }
  </code></pre>