anchor.diff:  $(function () {
     $(".js-previous").on("click", function() {
       var nextId = parseInt($(".js-previous").attr("data-id")) - 1;
  +    var numberOfPastPlans = parseInt($(".js-pager").attr("data-count")) - 1;
       $.get("/plans/" + nextId + ".json", function(data) {
         var date = new Date(data["date"]);
         var month = [];
  
positive.code:         ...
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-primary js-pager" data-id="<%= @plan.id %>">Previous</button>
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
  
negative.code:       $(".modal-body").html(purchasesString);
      });
      $(".js-pager").on("click", function() {
        if (numberOfPastPlans === 0) {
          $("#myModal").modal('hide');
        } else {
          numberOfPastPlans--;
          nextId--;
          $.get("/plans/" + nextId + ".json", function(data) {
            var date = new Date(data["date"]);
            var month = [];
            month[0] = "January";
            month[1] = "February";
            month[2] = "March";
            month[3] = "April";
            month[4] = "May";
            month[5] = "June";
            month[6] = "July";
            month[7] = "August";
            month[8] = "September";
            month[9] = "October";
            month[10] = "November";
            month[11] = "December";
            $(".modal-title").text(`In ${month[date.getMonth()]} you budgeted...`);
            var purchases = data["purchases"];
            var purchasesString = "";
            $.each(purchases, function(i, purchase) {
              purchasesString += `<p data-paymentid="${purchase["id"]}">` + "$" + `${purchase["price"]} ` + "for " + `${purchase["item"]} ` + "</p>";
            });
            $(".modal-body").html(purchasesString);
          });
        }
      });
    });
  });
  