title: Looping over array of objects
body: <p>I'm working on an asp.net app that is utilizing a lot of jQuery UI controls particularly the datepicker.</p>
  
  <p>In my web service I am making a call to the database and retrieving a list of objects and then passing them back to my javascript where I parse them out into an array containing 1 or more objects that look like this:</p>
  
  <p><a href="https://i.stack.imgur.com/qegeW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qegeW.jpg" alt="javascript object"></a>
  </p>
  
  <p>I need to include some kind of logic in which I can loop through this array of objects and check to see if a javascript Date falls in between the EndDate and StartDate properties of the object so that I can apply a css style for the DatePicker. First question, is there a way to convert the EndDate/StartDate property from this format to a valid javascript Date?
  And if so how can I iterate over the array and apply the logic to see if the date falls inside the range?</p>
  
  <p>Any help is greatly appreciated!</p>
  
  <p>Edit: I noticed the image here is kind of hard to see you can more clearly read the properties here:</p>
  
  <p><a href="https://postimg.cc/fVY8Zfhx" rel="nofollow noreferrer">image link</a></p>
  
  <p>As requested here is some example code:</p>
  
  <pre><code>function createDateRangesForCalendar() {
      $.ajax({
          type: "POST",
          url: "../Services/BookingService.asmx/GetCalendarDateRanges",
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          async: false,
          success: function (response) {
              dateRanges = $.parseJSON(response.d);
          },
          error: function (xhr, textStatus, thrownError) {
              alert(textStatus);
              alert(thrownError);
          }
      });
  }
  
  function markInvalidDates(date) {
  
      var isHoliday = false;
      dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear();
  
      isHoliday = checkIsHoliday(date);
  
      if ($.inArray(dmy, invalidDays) == -1) {
  
          for (var i = 0; i &lt; dateRanges.length; i++) {
              // if date falls in between start and end date of object[i] return something like: return [true, "holiday", "Holiday Rates Apply - Minimum 14 days"];
              // else loop through to the next object and try there
              } 
  
          if (isHoliday == true) {
              return [true, "holiday", "Holiday Rates Apply - Minimum 14 days"];
          } else {
              return [true, ""];
          }
      } else {
          return [false, "unavailable", "Unavailable"];
      }
  }
  </code></pre>